2

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

Community
  • 1
  • 1
Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
  • 2
    U can use the `features` option of `CucumberOptions` - @CucumberOptions(features = {"src/test/resources/first","src/test/resources/second"}) – Grasshopper Jun 28 '19 at 16:01
  • thanks @Grasshopper I will try same on Monday ... Another thing is how I can provide same from maven commond line instead of hard code in TestRunner java class – Shubham Jain Jun 28 '19 at 17:27
  • 1
    mvn test -Dcucumber.options="--features ........... – Grasshopper Jun 28 '19 at 17:47
  • 1
    `--features` is not a CLI argument. – M.P. Korstanje Jun 29 '19 at 07:36
  • @mpkorstanje Stand corrected. Any other way to pass the option? – Grasshopper Jun 29 '19 at 11:19
  • `cucumber.option` gets parsed as if it were the CLI so `mvn test -Dcucumber.options="path/to/file.feature"`. – M.P. Korstanje Jun 29 '19 at 11:28
  • It's not the best syntax. – M.P. Korstanje Jun 29 '19 at 11:28
  • 1
    @mpkorstanje for multiple folders will this work? `mvn test -Dcucumber.options="src/test/resources/first src/test/resources/second"` – Grasshopper Jun 29 '19 at 11:43
  • Yes. Everything that works on the command line works with `cucumber.options`. https://github.com/cucumber/cucumber-jvm/blob/master/core/src/main/java/io/cucumber/core/options/EnvironmentOptionsParser.java#L25 – M.P. Korstanje Jun 29 '19 at 18:08
  • Thanks both of you ... its working for me .. please put it as an answer, I will accept it @Grasshopper - your solution of cucumber tag always helps me .. thanks a lot ... mpkorstanje - Thanks for your input - mvn test -Dcucumber.options="src/test/resources/first src/test/resources/second" works :) ... – Shubham Jain Jul 03 '19 at 04:41

1 Answers1

3

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"

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
Grasshopper
  • 8,908
  • 2
  • 17
  • 32