serenity-bdd / serenity-cucumber-starter

A skeleton project for Serenity BDD and Cucumber JVM
Apache License 2.0
178 stars 280 forks source link

How do i register an AbstractStepListener #144

Open BlueBell-XA opened 2 months ago

BlueBell-XA commented 2 months ago

I've created a custom listener class under src/test/java/listeners, and implemented the AbstractStepListener.

public class CustomListener extends AbstractStepListener {
    // Implemented methods here.
}

However, I'm unable to get the listener registered, or picked up in any way.... none of the functions are triggered. Reason: I need access to the Scenario Outline examples before the test is executed. I figure that can be achieved through overriding the 'exampleStarted' methods.

I have already tried this Before hook:

    @Before
    public void before(Scenario scenario) {
        // Code here
    }

But the Scenario parameter doesn't have access to the outline examples... I can only see the Scenario Name, and tags.

BlueBell-XA commented 2 months ago

I haven't yet solved the original issue, but I have managed to achieve the outcome I was actually looking for.

    @BeforeScenario
    public void beforeScenario(TestOutcome outcome) {
    }

Adding TestOutcome as a parameter for a function tagged with @BeforeScenario grants me access to the full scenario details, including the DataTable/s associated with a Scenario Outline.