如何在Karate中执行其他目录中的功能文件

huangapple go评论153阅读模式
英文:

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')

huangapple
  • 本文由 发表于 2020年9月23日 20:58:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/64028515.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定