英文:
How to execute other directory feature files in karate
问题
我遇到了这样的情况,我正在 home.feature
中工作,需要调用 return.feature
并获取数据。而在内部,return.feature
正在调用 data.feature
并从中收集所有数据。
源代码
directory1
home.feature
directory2
return.feature
data.feature
我已经在 home.feature
中编写了以下内容:def response = call read('classpath:source/directory2/return.feature')
。
在调用这行代码时,它能够选择正确的特性文件,但在执行 return.feature
时,在调用 data.feature
时抛出错误(javascript 评估失败。java.io.FileNotFoundException)。
请指导我在 home.feature
文件中应该怎么做,因为我无法更改 directory2
中的内容。
提前谢谢。
英文:
I had a situation where i am working in home.feature and need to call return.feature and gets the data. And internally return.feature is calling data.feature and collects all the data from it.
Source
directory1
home.feature
directory2
return.feature
data.feature
I have written * def response = call read('classpath:source/directory2/return.feature') in home.feature.
while calling this line, it is picking up the correct feature file, but while executing return.feature, it throws error while calling data.feature(javascript evaluation failed. java.io.FileNotFoundException).
Please guide what could i do in home.feature file, as i dont have access to change in directory2.
Thanks in advance
答案1
得分: 1
这里有一个 this:
前缀: https://github.com/intuit/karate#reading-files
因此,在你位于 return.feature
内部时,这应该可以工作
* 调用 read('this:data.feature')
英文:
There is a this:
prefix: https://github.com/intuit/karate#reading-files
So this should work when you are inside return.feature
* call read('this:data.feature')
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论