com.intuit.karate.exception.karateeexception:原因:不是子字符串
我使用空手道框架V0.7.0来执行一些自动API测试 在以下场景中,我有一个测试返回异常com.intuit.karate.exception.KarateException:reason:不是子字符串 下面是以下场景:com.intuit.karate.exception.karateeexception:原因:不是子字符串,karate,Karate,我使用空手道框架V0.7.0来执行一些自动API测试 在以下场景中,我有一个测试返回异常com.intuit.karate.exception.KarateException:reason:不是子字符串 下面是以下场景: Scenario Outline: Put a number, and check the JSON response body. Given path '/number/check/' And param serial = '<number>' When met
Scenario Outline: Put a number, and check the JSON response body.
Given path '/number/check/'
And param serial = '<number>'
When method GET
Then status 200
And match $ contains {"uid":"#uuid","reference":"#notnull","type":"#notnull","name":"#notnull","description":"#notnull","imageUrl":"#notnull","color":"<color>","reason":"<reason>"}
Examples:
| number | color | reason |
# Case 1
| 1234 | RED | INITIAL_WARRANTY_EXPIRED |
# Case 2
| 5678 | RED | INELIGIBLE_PRODUCT_FAMILY |
# Case 3
| 9012 | RED | ALREADY_EXTENDED |
我已经手动检查了,这是案例3的JSON答案:
[{"uid":"2cd897fd-1421-4c02-b594-6ee0de38db3d","reference":"a random reference","type":"a random type","name":"a random name","description":"a random description","imageUrl":"a random image url","color":"RED","reason":"ALREADY_EXTENDED"}]
我不明白为什么只有案例3失败了
有什么想法吗
非常感谢
编辑1:“引用”是错误的复制粘贴。对此表示抱歉。更新:
经过调查,完全相同的测试在由JUnit启动时运行良好,但在使用Maven启动时运行不好。这是编码方面的问题
解决方案:使用以下命令强制在Surefire插件中进行编码:
<argLine>-Dfile.encoding=UTF-8</argLine>
mvn clean test -DargLine="-Dkarate.env=YOUR_ENV"
使用语法很重要
<argLine>${argLine} -Dfile.encoding=${project.build.sourceEncoding}</argLine>
${argLine}-Dfile.encoding=${project.build.sourceEncoding}
…而不仅仅是
<argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
-Dfile.encoding=${project.build.sourceEncoding}
否则,Maven-DargLine将被POM.xml中的一条覆盖。太好了!投票结果:)感谢您提供的详细信息,这肯定会帮助其他人。
<argLine>${argLine} -Dfile.encoding=${project.build.sourceEncoding}</argLine>
<argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>