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