![](/img/trans.png)
[英]Setting global variables in karate from one feature to be used in another feature
[英]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()
您的功能文件并且两个功能都在同一场景中即可。
假设您要将值从Admin
传递到Store
功能中的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),我只想运行scenario1。 有可能实现这一目标吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.