我可以使用空手道 dsl 将值从一个文件夹的一个特征文件传递到 /src/java/test 下另一个文件夹的另一个特征文件吗

Can I pass values from one feature file of one folder to another feature file of another folder under /src/java/test using karate dsl

我的项目结构是这样的:

/src/java/test

TestRunner -> main.java
Component1 --> Admin.feature
Component2 --> Publisher.feature
Component3 --> Store.feature

我想将一些值从 Admin.feature 文件传递​​到 Publisher.feature 文件。 这可能吗?

我知道我们可以将值从一个特征文件传递到同一文件夹下的另一个特征文件,但我不确定该值是否可以在我的整个文件夹结构中使用。

是的,只要您能够 read() 您的功能文件并且两个功能都在同一场景中。

假设您要在 Store 特征中将值从 Admin 传递到 Publisher

Store.feature

Scenario:
    * def getAdmin = call read('classpath:Component1/Admin.feature') {"SomeInput":"toAdmin"}
    * def getPublisher = call read('classpath:Component2/Publisher.feature') {"Admin": "#(getAdmin.response)"}

现在在您的 Publisher.feature 中,您可以在 Admin 变量

中获取管理员响应的详细信息

注意:要查找 /src/java/test 目录下的任何文件,您可以使用 classpath: 作为前缀,如上例中所述。

假设我在调用的功能(带有标签=@scenario)中有多个场景,我只想 运行 场景 1。有可能实现吗?