1
我能够使用json文件在特性文件中解析我的凭证。 如:空手道API测试 - 使用xml代替json
* def credentials = read('classpath:credentials.json')
* header Authorization = call read('classpath:basic-auth.js') { username: '#(credentials.user)', password: '#(credentials.pwd)' }
这里是凭据JSON文件:
{
user: 'abc',
pwd: 'def'
}
然而,当我尝试使用XML文件,而不是,我不能够通过分析它:
凭证XML文件:
<?xml version="1.0" encoding="UTF-8" ?>
<credentials>
<user>abc</user>
<pwd>def</pwd>
</credentials>
我将功能文件更改为:
* def credentials = read('classpath:credentials.xml')
* header Authorization = call read('classpath:basic-auth.js') { username: '#(<credentials><user></credentials>)', password: '#(<credentials><pwd></credentials>)' }
我是否需要对解析xml的方式进行任何更改?任何建议,将不胜感激。提前致谢!!
我想一起去JSON文件,但产生的黄瓜报告时,它拿起credentials.json文件,并返回以下错误: net.masterthought.cucumber.ValidationException:文件“** /工作/# ####/jobs/####/builds/5/cucumber-html-reports/.cache/test-classes/credentials.json'不正确黄瓜报告! – Saurabh
咦!?这绝不应该发生。将报告XML和JSON的输出文件夹设置为像“target/surefire-reports”这样的明智之举:https://github.com/intuit/karate/tree/master/karate-demo#example-report –
我已经设置了karateOutputPath =“target/surefire-reports”; 另外,通过jenkins我并行运行它: test -Dcucumber.options =“ - plugin junit:target/cucumber-junit.xml --tags〜@ ignore”-Dtest = TestParallel -DargLine = -Dkarate.env = qa – Saurabh