我正在尝试调用一个功能文件,它也在调用另一个文件。我调用的功能在另一个目录中。 因此,当我执行场景时,它在错误的地方查找。
这是一个例子:
-scenarios
--directoryA
---feature1
---feature2
--directoryB
---feature3
Feature: feature2
Scenario: scenario2
* url testUrl
* def testCall = call read('feature1.feature')
Given request { test: 'test' }
When method post
Then status 201
Feature: feature3
Scenario: scenario3
* url testUrl
* def testCall = call read('classpath:scenarios/directoryA/feature2.feature')
Given request { test: 'test' }
When method post
Then status 201
我在执行功能 3 后得到的错误:
feature2.feature:9 - javascript evaluation failed: read('feature1.feature'), java.io.FileNotFoundException: /Users/svetoslavlazarov/project/src/test/java/scenarios/directoryB/feature1.feature (No such file or directory)
这里的问题是对 feature1 的调用在错误的目录中。 它应该查看 directoryA,而不是 directoryB。 但是,如果我独立执行场景 2,就没问题。
你能帮我解决这个问题吗? 谢谢。
最佳答案
试试这个:
* def testCall = call read('this:feature1.feature')
关于karate - 调用 Karate 功能,其中包括内部的另一个调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56937493/