Search code examples
cucumber-jvm

How to pass dynamic folder name for HTML reports in @CucumberOptions


Currenlty, Im passing path of HTML report generation via CucumberOptions in Runner class. however with each run the old report gets overwritten. is there a way to pass new folder name with each run or inbuilt cucumber option to generate new folder name for each run?

here is my code:

@CucumberOptions( features = "src/test/resources/features", glue="com.bnymellon.sse.ui.step_definitions", tags = {"@demo"}, monochrome = true, plugin = {"html:output/HTML_Reports/"} )


Solution

  • There are three ways to override Cucumber Options.

    1. cucumber.options="..." passed to the JVM with -Dcucumber.options="...".
    2. The environment variable CUCUMBER_OPTIONS="...".
    3. A cucumber-jvm.properties on the CLASSPATH with a cucumber.options="..." property.

    There is a caveat; you cannot override, but only add a plugin. So you would need to remove the html plugin from your @CucumberOptions and specify the html plugin using one of the 3 methods listed above.

    If you just want to avoid having to edit your runner class for each run then I would move the html plugin to:

    -Dcucumber.options="--plugin html:output/HTML_Reports"
    

    on your runner's VM arguments box. You can then edit VM arguments before each run which avoids triggering git. I often override the tags argument this way.