prashant-ramcharan / courgette-jvm

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

Can't access to the overridden Cucumber options #373

Closed martinmineo closed 1 year ago

martinmineo commented 1 year ago

Hi! I hope you are doing well :) Some context first: In my test runner file, I have these Courgette and Cucumber options set

@CourgetteOptions(
        threads = 10,
        runLevel = CourgetteRunLevel.FEATURE,
        testOutput = CourgetteTestOutput.CONSOLE,
        reportTitle = "API Automation Results",
        reportTargetDir = "reports/courgette-report",
        environmentInfo = "Staging API",
        slackWebhookUrl = "https://hooks.slack.com/services/T00000000/B00000000000000000000000000000000000",
        slackChannel = {"some_channel"},
        slackEventSubscription = {
                CourgetteEvent.TEST_RUN_STARTED,
                CourgetteEvent.TEST_RUN_SUMMARY},
        cucumberOptions = @CucumberOptions(
                features = "src/test/resources/features",
                glue = "stepdefs",
                tags = "@wip",
                publish = true,
                plugin = {
                        "pretty",
                        "json:reports/courgette-report/cucumber-report/cucumber.json",
                        "html:reports/courgette-report/cucumber-report/cucumber.html",
                        "io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm"
                }
        ))

Check that the cucumberOption -> tags = "@wip"

Then, I run my tests through the terminal using

mvn test -Dcucumber.tags="@smoke"

And when I get the tags in the code

CourgetteRunInfo.courgetteOptions().cucumberOptions().tags())

I get "@wip" and not "@smoke" as I was expecting.

Note: I'm using Courgette version 6.8.0

Is there a way to get the overridden value of the tags?

Thanks!

prashant-ramcharan commented 1 year ago

Hello,

You could get the tags from the system property you pass at runtime.

System.getProperty("cucumber.tags")

To check

System.out.println("Tags defined in runner -> " + Arrays.toString(CourgetteRunInfo.courgetteOptions().cucumberOptions().tags()));

System.out.println("Tags passed at runtime -> " + System.getProperty("cucumber.tags"));
martinmineo commented 1 year ago

Thank you! That worked. Let me ask you something else. Is there a way to override the report title at runtime and send that information over slack? I'd like to send that information here 👇 Screenshot 2023-03-02 at 12 06 03

As you can see, I want to include more information in that message so it's clearer for the team when these messages are sent

prashant-ramcharan commented 1 year ago

You can use the following:

To pass a Test Id to slack notifications at runtime:

-Dcourgette.slackTestId="Whatever information you want to add here"

To override the report title at runtime:

-Dcourgette.reportTitle="Your report title here"
martinmineo commented 1 year ago

thank you very much!!

You are doing a great job here