prashant-ramcharan / courgette-jvm

Multiprocess | Parallel Cucumber-JVM | Parallelize your Java Cucumber tests on a feature level or on a scenario level.
MIT License
132 stars 38 forks source link

How to specify Feature/Scenario Tags from withing Gradle Task instead of the .java files. #12

Closed chakraborty-rupam closed 6 years ago

chakraborty-rupam commented 6 years ago

Hi, I'm looking for a way to control the test execution tags from gradle command level instead of mentioning it inside the XXSutie.java file. Something similar to gradlew -Dcucumber.options=""--tags @xx" , is it possible?

This would give me flexibility in choosing what to run in a CI/CD env at runtime. Please suggest a way.

prashant-ramcharan commented 6 years ago

Hi,

This is indeed possible. Would add this feature in the next release.

In the mean time, you could use an runtime parameter in the CI tool to control which test suite to run.

Example.. In your build.gradle, you could have 2 tasks

  1. runRegression (with all features / scenarios that are tagged with "@ regression")
  2. runSanity (_with all features / scenarios that are tagged with "@ sanity")

In your CI job, you add 2 runtime parameters called runRegression and runSanity and you simply select the suite you want to run.

Your CI job would then either run gradlew runRegression or gradlew runSanity

chakraborty-rupam commented 6 years ago

Thanks Prashant.

prashant-ramcharan commented 6 years ago

Hi,

This is now released in version 1.4.1.

Refer to the README for more info.

chakraborty-rupam commented 6 years ago

Thanks a lot for getting this included so quick, i was able to work with 1.41 release. Would I be able to use the Courgette Options in a similar way? Also, if I miss out to provide the input values (via cmd line) would they default to any specific value?

prashant-ramcharan commented 6 years ago

No, you will not be able to use the Courgette Options in the same way. This is because we still require a runner class to encapsulate these options (note. Courgette does not have a CLI)

If you omit the run parameters in the command line, then Courgette will simply use the default values defined in the runner class.

The options you specify in the command line just overrides the cucumber options defined in the runner.

chakraborty-rupam commented 6 years ago

Alright, got it. thanks.

prashant-ramcharan commented 6 years ago

Courgette options can now be overridden at runtime. Refer to release 1.5.0

seanleblanc commented 6 years ago

I saw your comment on the cucumber issues about courgette-jvm. I was wondering the same thing about the annotation vs. being more dynamic, but now looks like this is fixed? Do you have any examples of this anywhere? I also would like to be able to take options on command line (to Gradle) and pass along, most especially the tag or tags to run.

prashant-ramcharan commented 6 years ago

@seanleblanc - You can use the Courgette-JVM example project

Refer to README.md for full usage.

But you can override courgette options and cucumber options from the command line (tags etc..)

Courgette Options

gradle regressionSuite -Dcourgette.threads=2 -Dcourgette.runLevel=FEATURE -Dcourgette.rerunFailedScenarios=false

Cucumber Options

gradle regressionSuite -Dcucumber.tags="@regression, not @bug" -Dcucumber.glue="steps"
seanleblanc commented 6 years ago

Is there anything that needs to be added to have it find .groovy files? We use Groovy for step files, etc, and it does not seem to find the steps files since it outputs how the missing steps could be implemented with some snippets, and does not run any scenarios.

prashant-ramcharan commented 6 years ago

Instead of using a package name holding the step files, you need to provide the path to the steps files.

Example If your steps are in a package com.something.steps

In your runner you will need to specify the glue as a PATH src/test/com/something/steps

Similar question answered https://github.com/prashant-ramcharan/courgette-jvm/issues/36