4

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.

1 Answer 1

1

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?

Sign up to request clarification or add additional context in comments.

8 Comments

This works but every time i call the other feature , it executes the feature steps again and then gives the newly generated values of the variables. What i really want is , call another feature and fetch the last saved value from that feature . Is that possible?
@sneha If you want to run any feature only on time instead of using call use callonce, then it will not rerun and you will get the last generated value only
* def getAdmin = callonce read('classpath:Component1/Admin.feature') {"SomeInput":"toAdmin"}
So if I do * def getAdmin = callonce read('classpath:Component1/Admin.feature') {"SomeInput":"toAdmin"} once and then do * def getAdmin = call read('classpath:Component1/Admin.feature') {"SomeInput":"toAdmin"} at other places where i want to use it, then the second statement is going to just call the feature and take the last generated values ?
@BabuSekaran - Is it possible to reference a feature file in another maven project directory which is within the same workspace through the use of read() ? I would like to re-use an authentication feature throughout multiple projects but would like to only write the log in feature once rather than in multiple places throughout my project.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.