![](/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.