gpt4 book ai didi

Karate DSL : Unable to convert string characters from different languages while reading json file

转载 作者:行者123 更新时间:2023-12-02 09:50:55 25 4
gpt4 key购买 nike

我试图将整个响应与 json 文件匹配。

    Background:
* url BaseURL
* def resp = read('response_get_discount.json') // Reading json file

Scenario: Verify Users discount
Given path '/discount'
When method get
Then status 200
* match response == resp //Trying to match whole response with the output of the above json file

问题:

我的 json 文件在西类牙有以下输出:

    {
"familyCode": "DH",
"validityStart": 1575500400000,
"description": "Aparamenta modular Limitadores sobretensiones + Gestión Energía (SPD + CCB)"
}

请注意“Gestión Energía”一词,当它从文件读取时,它会被转换为“Gestión Energía”。因此它无法与响应与响应匹配。

有没有办法忽略或处理此类编码字符?

最佳答案

请阅读文档中的此部分:https://github.com/intuit/karate#fileencoding

The solution is to ensure that when Karate tests run, the JVM file.encoding is set to UTF-8. This can be done via the maven-surefire-plugin configuration. Add the plugin to the <build>/<plugins> section of your pom.xml if not already present:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>

编辑:这是一个文件编码问题 - 请参阅评论

I have figured out the fix as per your suggestion. Since I was using eclipse , i did below steps to encode json properly. Windwos -- preferences -- General -- Workspace : Under Text encoding , selected Others -- UTF-8. Apply and restart ecplise.

关于 Karate DSL : Unable to convert string characters from different languages while reading json file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59208117/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com