How can we run only specific cukes with Cucumber - cucumber

I do understand that cucumber itself not providing any such functionality where we can run specific few cukes from cucumber.
Note: from cukes I meant multiple folder having different feature files
For Example:
Folder1:
-> one.feature
-> two.feature
Folder2:
-> three.feature
-> four.feature
Folder3:
-> five.feature
-> six.feature
Now suppose if I like to run only Folder1 and Folder2 without specify any tag in cucumber file then how we can achieve it in cucumber
I like to execute few cukes folder not all of them and I do understand that I need to override the current functionality of cucumber for same.
I would like to know if someone already done it already, if yes please share with us.
I also like to know how I can trigger same from maven command

U can use the features option of CucumberOptions -
#CucumberOptions(features = {"src/test/resources/first","src/test/resources/second"})
From the maven command-
mvn test -Dcucumber.options="src/test/resources/first src/test/resources/second"

Related

Run separated cucumber files chained

I am studying Appium with cucumber
And I have different cucumber scenarios, for example:
login.feature with LoginSteps.java and Login.java to do actions with the app
I need to add more scenarios and I want to make different files like help.feature, payment.feature, etc.
All these scenarios need to do a login before, so, they need to get LoginSteps before to do HelpSteps
LoginSteps -> HelpSteps
LoginSteps -> PaymentSteps
...
What is the best way or the best architecture to build this kind of project?
Any reference is welcome.

How to set path of step Definition file , if my feature file ,stepDefinition file and runner file resides in separate folders?

I am using maven project for cucumber execution and below is my project explorer view.
Project Explorer
I want to instruct "SimpleDataDriverRunner.java" file to execute "SimpleDataDriverStepDefinition.java" class. Both these files are present in different folder structure (as shown in image above).
Below is my runner class
#RunWith(Cucumber.class)
#CucumberOptions(
features="dir path\\com\\features\\SimpleDataDriven.feature",
glue= {"stepDefinition"},
monochrome=true
)
Can someone please guide me how to achieve this and if this is correct way to deal with multiple runner file and step definition files ?
If there is any BDD cucumber sample project having multiple feature, step Definition and runner files is much appreciated .
I never understood why multiple runners are needed, if is just to run different scenarios it doesn't seem very efficient.
I would use just one runner and select what to run by tags.
Annotate your feature with some tag like #someTag and run it.
E.g.:
mvn test -Dcucumber.filter.tags="#someTag"
From cucumber documentation:
cucumber.features= # command separated paths to feature files. example: path/to/example.feature, path/to/other.feature
cucumber.glue= # comma separated package names. example: com.example.glue
Try adding in glue the package for runners also:
glue= {"stepDefinition", "runner"},

I want to merge one project data into another project in jenkins. How can I achieve this?

I have two project namely say X and Y
Where x contains all code and configuration
And Y contains testData and Feature files which is manage by some other team.
I had created a job in jenkins to run my X project initially which is working without any issue. Now I want at run time I poll the Y project and check if they had any new commits then first I merge it else leave it.
Currently I am able to check the last commit but still not able to merge project
My both X and Y are Karate API project
I think you need to design differently. Maybe the right solution is X should create a JAR file. And then in Y you depend on that JAR file. Now it has become a standard CI / Jenkins situation.
My advice is don't try to re-invent polling and merging and whatnot - those are all solved problems.
I achieve this using git submodule concept and it not required anything to done on CI.
git submodule add <repository URL

Using cucumber to run different tagged features sequentially

I'm attempting to run tagged features in the order that they are submitted.
example:
I have tests that i'd like to run in a specific order (#test1, #test2, #test3). After looking at the cucumber documentation is looks like i'm only able to run them in an and/or option like
cucumber features/.feature --t #test1; cucumber features/.feature --t #test2; cucumber features/*.feature --t #test3;
but this prevents me from having a single report which contains all of the results.
Is there anyway which I can run these tests in their respective order and have all of the results contained in the same report?
If you put the tests that have to run in a specific order in a feature file together cucumber will run them in the order they are given. As this will be in your normal test run it should all show up in the same report.
But it might be worth looking into why your tests are dependant on each other and if there is a way to remove this dependancy as it is generally bad practice to have it.

How to execute .feature file in cucumber

I am a beginner to Cucumber. I have installed cucumber by the help of internet. I have written a .feature file. But I don`t know where to place this file and how to execute it.
Because it wants you to succeed in BDD, cucumber will guide you through the process. From the project directory, type cucumber in the cmd prompt or terminal, which returns:
You don't have a 'features' directory. Please create one to get started.
Create a features directory, and put your .feature file in it. Again, run cucumber, which returns pending step definitions that map to your feature file. As an example:
You can implement step definitions for undefined steps with these snippets:
Given /^I want to use cucumber$/ do
pending # express the regexp above with the code you wish you had
end
Now--as #siekfried indicates--create a directory called features/step_definitions for your step definition files, which should end with _steps (e.g. example_steps.rb). Then, edit your step definition file with the appropriate code to execute the step.

Resources