/allure-cucumber-jvm-example

Example of usage Allure Report with Cucumber-JVM and Maven

Primary LanguageGherkin

Allure Cucumber-JVM Examples

Getting Started

To run tests you need to install maven and git.

To generate Allure Report you should perform following:

NOTE: required maven version 3.1.1 or above

OnFailureSchedulerCallback

This feature let users to schedule events on test failure. That's how it works:

  • Create callback class which implements OnFailureCallback and add some logic into overriden call() method:
public class FailureCallback implements OnFailureCallback {
    @Override
    public Object call() {
        return 10;
    }
}
  • To schedule callback action on test failure just put it into @Before section.
  • To get callback result ask it on @After stage.
import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;

public calss StepDefinitions {
    @Before
    public void before() {
        AllureReporter.applyFailureCallback(FailureCallback.class);
    }

    @Given("some regex")
    public void someFailedStep(){ /* Some code which leads to error */}

    @After
    public void after() {
        int result = AllureReporter.getFailureCallbackResult();
        Assert.assertEquals(10, result);
    }
}

So you can do everything you want in call() method: attach screenshots, rotate logs, etc. And you always can get callback result in @After section

More