You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When throwing an AssumptionViolatedException in steps (somewhere in your test case anyway) Serenity will handle this as SKIPPED and will record the test case as IGNORED.
But this is not the case when throwing an AssumptionViolatedException in Cucumber event listeners plugin.
Below you can find my custom cucumber listener:
package base.runner.plugins;
import io.cucumber.plugin.EventListener;
import io.cucumber.plugin.event.EventPublisher;
import io.cucumber.plugin.event.TestCaseStarted;
import org.junit.AssumptionViolatedException;
public class BeforeTestCase implements EventListener {
@Override
public void setEventPublisher(final EventPublisher publisher) {
publisher.registerHandlerFor(TestCaseStarted.class, this::onTestCaseStarted);
}
private void onTestCaseStarted(final TestCaseStarted event) {
throw new AssumptionViolatedException("skip");
}
}
And of course the runner:
package base.runner;
import io.cucumber.junit.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;
import org.junit.runner.RunWith;
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
plugin = {"pretty","base.runner.plugins.BeforeTestCase"},
features = "src/test/resources/features",
glue = "steps",
tags = ""
)
public class Cucumber {}
I don't know if that is even an issue, or it has been already reported in the past.
Seems pretty strange.
The text was updated successfully, but these errors were encountered:
I can see in the code this isn't catered for - it will just be silently skipped, as . Handling it looks non-trivial, as the Serenity listeners are bypassed in that case (the test is simply not run, which is the normal behaviour for an AssumptionViolatedException). Could be a future enhancement.
There are many ways to achieve that. As an example you can use cucumber hooks (@before) and throw the assumption there. I just want to have everything in place.
When throwing an AssumptionViolatedException in steps (somewhere in your test case anyway) Serenity will handle this as SKIPPED and will record the test case as IGNORED.
But this is not the case when throwing an AssumptionViolatedException in Cucumber event listeners plugin.
Below you can find my custom cucumber listener:
And of course the runner:
I don't know if that is even an issue, or it has been already reported in the past.
Seems pretty strange.
The text was updated successfully, but these errors were encountered: