karate.callSingle 在空手道中找不到 .feature 文件-config.js
karate.callSingle not found .feature file in karate-config.js
我正在使用 karate v0.9.6,这是一个很棒的工具。
我有超过 1000 个场景,每个场景都需要令牌才能工作,所以我在 karate-config.js 中使用 callSingle 来创建和缓存令牌。我使用独立的 jar 文件。
我的部分空手道-config.js:
var auth_cfg = {
server: env,
credentials: karate.properties['credentials']};
var result = karate.callSingle('classpath:credentials/generate_tokens.feature', auth_cfg);
我正在使用这样的 .sh 文件:
rm -rf target &&
java -Xmx2048m \
-Dlogback.configurationFile=cfg/logs_debug.xml \
-jar \
-Dcredentials=data.json \
karate-1.0.1.jar -e https://my-server/ \
--tags ~fixme \
--tags ~ignore \
--threads 4 \
features/services/simple_plan.feature
而且,它在 v.0.9.6 上长时间运行完美。
但是,当我尝试升级到 v 1.0 或 1.0.1 时,出现错误:
org.graalvm.polyglot.PolyglotException: not found: credentials/generate_tokens.feature
我发现了这个问题:https://github.com/intuit/karate/issues/1515
但是示例对我不起作用。我正在尝试使用“file:”和 karate.properties['karate.config.dir'] + '/features/auth/auth.feature'。
我总是收到错误消息:
not found: credentials/generate_tokens.feature
还有谁遇到过这个问题?
正如您在#1515 的讨论中看到的那样 - 这就是为什么我们真的希望更多人尝试 RC 版本并向我们提供反馈(我们为此花费了几个月)而不是等待 1.0。
你的情况似乎是一个边缘案例,你正在使用独立的 JAR 和自定义 shell 脚本。
我的第一个建议是使用 -w
标志。这是 1.0 中的一个新参数,可以设置“当前工作目录”,但它应该在您的情况下正确默认。
第二个建议是为JVM 设置类路径。使用此作为参考: - 一旦您这样做,classpath:
将按您预期的那样工作。
否则请遵循以下过程:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue - 我不得不说,除非你能帮助我们解决这个问题,否则你可能不得不在 0.9.6 上停留一段时间。对不起。
Peter Thomas,感谢您的快速回复!
我修改了 callSingle 函数和由 callSingle 调用的 .feature 文件 - 将“类路径:”更改为“文件:”
karate.callSingle('file:credentials/generate_tokens.feature', auth_cfg)
,
# read credentials
* def authdata = read('file:credentials/' + credentials)
现在可以使用了。之前,当我将 classpath: 更改为 file: i 时,可能犯了一个错误。
感谢这么棒的测试框架!
我正在使用 karate v0.9.6,这是一个很棒的工具。 我有超过 1000 个场景,每个场景都需要令牌才能工作,所以我在 karate-config.js 中使用 callSingle 来创建和缓存令牌。我使用独立的 jar 文件。
我的部分空手道-config.js:
var auth_cfg = {
server: env,
credentials: karate.properties['credentials']};
var result = karate.callSingle('classpath:credentials/generate_tokens.feature', auth_cfg);
我正在使用这样的 .sh 文件:
rm -rf target &&
java -Xmx2048m \
-Dlogback.configurationFile=cfg/logs_debug.xml \
-jar \
-Dcredentials=data.json \
karate-1.0.1.jar -e https://my-server/ \
--tags ~fixme \
--tags ~ignore \
--threads 4 \
features/services/simple_plan.feature
而且,它在 v.0.9.6 上长时间运行完美。 但是,当我尝试升级到 v 1.0 或 1.0.1 时,出现错误:
org.graalvm.polyglot.PolyglotException: not found: credentials/generate_tokens.feature
我发现了这个问题:https://github.com/intuit/karate/issues/1515
但是示例对我不起作用。我正在尝试使用“file:”和 karate.properties['karate.config.dir'] + '/features/auth/auth.feature'。 我总是收到错误消息:
not found: credentials/generate_tokens.feature
还有谁遇到过这个问题?
正如您在#1515 的讨论中看到的那样 - 这就是为什么我们真的希望更多人尝试 RC 版本并向我们提供反馈(我们为此花费了几个月)而不是等待 1.0。
你的情况似乎是一个边缘案例,你正在使用独立的 JAR 和自定义 shell 脚本。
我的第一个建议是使用 -w
标志。这是 1.0 中的一个新参数,可以设置“当前工作目录”,但它应该在您的情况下正确默认。
第二个建议是为JVM 设置类路径。使用此作为参考:classpath:
将按您预期的那样工作。
否则请遵循以下过程:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue - 我不得不说,除非你能帮助我们解决这个问题,否则你可能不得不在 0.9.6 上停留一段时间。对不起。
Peter Thomas,感谢您的快速回复! 我修改了 callSingle 函数和由 callSingle 调用的 .feature 文件 - 将“类路径:”更改为“文件:”
karate.callSingle('file:credentials/generate_tokens.feature', auth_cfg)
,
# read credentials
* def authdata = read('file:credentials/' + credentials)
现在可以使用了。之前,当我将 classpath: 更改为 file: i 时,可能犯了一个错误。 感谢这么棒的测试框架!