本文介绍了使用独立的karate.jar运行测试时无法使用read('classpath:')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用空手道独立罐子执行测试.在我的整个项目中,查找文件时都使用read('classpath:').

I am attempting to execute my tests using the karate stand-alone jar. Throughout my project, I use the read('classpath:') when locating files.

但是,当我尝试从CLI执行测试时,出现以下错误:

However, when I attempt to execute my tests from the CLI, I receive the following error:

src.test.java.Users.getUser: -unknown-:6 - javascript evaluation failed: read('classpath:commonUtils.feature'), java.io.FileNotFoundException: commonUtils.feature (The system cannot find the file specified)命令:java -jar -Dkarate.config.dir="src/test/java" karate.jar -e DEV -t @tests src/test

似乎我必须在执行时声明类路径,请问您能否提供一些有关如何执行此操作的见解?我不确定我的问题是否链接到 [karate] [standalone ]错误:找不到或读取文件

It seems that I will have to declare the classpath on execution, would you be able to provide some insight on how to do this please? I'm not sure whether my issue is linked to [karate][standalone] Error : could not find or read file

推荐答案

可以尝试 ZIP版本,如果打开karate批处理文件,则会看到以下内容:

Can you try the ZIP release and if you open the karate batch file you will see this:

java -cp karate.jar:. com.intuit.karate.Main $*

因此,设置自定义类路径的技巧是使用com.intuit.karate.Main入口点,并且在上面的示例中,当前目录也添加到了类路径中.

So the trick to setting a custom classpath is to use the com.intuit.karate.Main entry point and in the above example the current dir is also added to the classpath.

如果您尝试使用当前的RC版本(0.9.5.RC3),以确保我们能够按预期运行所有功能,那就太好了.

It would be great if you try the current RC version (0.9.5.RC3) to ensure we have everything working as expected.

有关更多信息,请参阅文档的此部分: https://github.com/intuit/karate/tree/develop/karate-netty#custom-classpath

For more information, see this part of the docs: https://github.com/intuit/karate/tree/develop/karate-netty#custom-classpath

这篇关于使用独立的karate.jar运行测试时无法使用read('classpath:')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 18:48