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 a step inside Lifecycle>After>FAILURE throws an assertion, you get a NPE:
Caused by: java.lang.NullPointerException
at org.junit.runner.notification.Failure.getTestHeader(Failure.java:44)
...
at com.github.valfirst.jbehave.junit.monitoring.JUnitScenarioReporter.failed(JUnitScenarioReporter.java:273)
...
The expression testState.currentStep evaluates to null and passed further.
You can reproduce with these files:
Steps file:
package com;
import org.jbehave.core.annotations.Then;
import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TestSteps {
@Then("I assert with message $assertMessage")
public void assertWithMessage(String assertMessage) {
Assert.fail(assertMessage);
}
}
Story file:
Lifecycle:
After:
Outcome: FAILURE
Then I assert with message AfterAssert1
Scenario: Test lifecycle
Then I assert with message ScenarioAssert1
The NPE does not occur if the step in the After>FAILURE does not throw an assert.
Similarly, the NPE does not occur if I use Outcome=ANY instead of FAILURE
Hi,
When a step inside Lifecycle>After>FAILURE throws an assertion, you get a NPE:
Full stack trace here: mvn_NPE.txt
I saw that the cause of the null is here - https://github.com/valfirst/jbehave-junit-runner/blob/master/src/main/java/com/github/valfirst/jbehave/junit/monitoring/JUnitScenarioReporter.java#L273
The expression
testState.currentStep
evaluates tonull
and passed further.You can reproduce with these files:
Steps file:
Story file:
The NPE does not occur if the step in the After>FAILURE does not throw an assert.
Similarly, the NPE does not occur if I use Outcome=ANY instead of FAILURE
Relevant mvn dependency:
Thanks.
The text was updated successfully, but these errors were encountered: