prashant-ramcharan / courgette-jvm

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

Trouble with report-attacments #283

Closed vgt1337 closed 3 years ago

vgt1337 commented 3 years ago

Good day, Prashant! Can you help me with add attachment in allure report right in failed step not in TearDown methods? image You wrote "Each feature / scenario is run using the Cucumber CLI and because of this JUnit is not notified off the result whilst the tests are being executed." - is it fixed?

prashant-ramcharan commented 3 years ago

Hi @vgt1337

Did you try using the AfterStep cucumber hook?

You can add something like this:

    @AfterStep
    public void afterStep(Scenario scenario) {
        if (scenario.isFailed()) {
            // take screenshot here
        }
    }

You wrote "Each feature / scenario is run using the Cucumber CLI and because of this JUnit is not notified off the result whilst the tests are being executed." - is it fixed?

JUnit is currently notified of the result after all tests are run.

vgt1337 commented 3 years ago

Yes, this way also added attachments in TearDown method image

prashant-ramcharan commented 3 years ago

You will have to embed the screenshot in the step definition although I would not recommend this approach.

    @Given("step will fail sometimes")
    public void stepWithFailure() {
            scenario.attach(...);
    }

It's unlikely you will know when a step will fail so it's best to capture the (failed) state of your application (i.e. image attachment) in a hook.

Courgette uses the allure-cucumber6-jvm plugin so all allure report features are defined in this plugin.