如何使用绝对路径而不是类路径来读取文件

时间:2019-04-15 04:02:38

标签: automated-tests karate

我想将所有资源文件/脚本/有效负载存储在一个程序包中并通过调用功能,我想读取该文件或脚本。在这种情况下使用classpath会造成问题。

在空手道配置中,我将一个变量设置为application_path,并具有要在功能文件中引用的绝对路径

空手道配置

{
application_path:"/home/local/IdeaProjects/project/src/test/java/module"
}

任何人都可以帮助您设置或使用绝对路径

1 个答案:

答案 0 :(得分:1)

当然不建议这样做,但是我们为绝对路径支持file:前缀。

请参考文档:https://github.com/intuit/karate#reading-files

* def payload = read('file:/home/foo/bar.json')