简体   繁体   中英

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

My project structure is something like this:

/src/java/test

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

I want to pass some value from Admin.feature file to Publisher.feature file. Is that possible?

I know we can pass values from one feature file to another under the same folder, but I'm unsure if the value can be used throughout my folder structure.

Yes, as long as you are able to read() your feature file and both the features are in the same scenario.

Let's say you want to pass values from Admin to Publisher inside a Store feature.

Store.feature

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

now inside your Publisher.feature you can get the admin response details in the Admin varaible

Note: To find any file under /src/java/test directory you can prefix with classpath: as mentioned in the above example.

Lets say I have multiple scenariosinside my called feature (with tags=@scenario) and I only want to run scenario1. Is it possible to achieve that?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM