-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NullPointerException from @Before tag #701
Comments
Hi all, Here is the trace:- |
This issue will be fixed when Cucumber-JVM is updated to use Gherkin v4 (#1035), until then do not use before hooks calling write together with the Json Formatter. |
Now when #1035 has been merged, the 2.0.0-SNAPSHOT version from the master branch (with the groupId io.cucumber), the Json Formatter handles writes from before hooks correctly. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
The following is printed from JUnit, though it does not fail the build:
[junit] Testcase: | DefaultUser | allowExplicit | @{censoredLyricsJSON} | took 0 sec
[junit] Caused an ERROR
[junit] null
[junit] java.lang.NullPointerException
[junit] at gherkin.formatter.JSONFormatter.getSteps(JSONFormatter.java:235)
[junit] at gherkin.formatter.JSONFormatter.getCurrentStep(JSONFormatter.java:65)
[junit] at gherkin.formatter.JSONFormatter.getOutput(JSONFormatter.java:253)
[junit] at gherkin.formatter.JSONFormatter.write(JSONFormatter.java:136)
[junit] at cucumber.runtime.Utils$1.call(Utils.java:34)
[junit] at cucumber.runtime.Timeout.timeout(Timeout.java:13)
[junit] at cucumber.runtime.Utils.invoke(Utils.java:30)
[junit] at cucumber.runtime.RuntimeOptions$2.invoke(RuntimeOptions.java:192)
[junit] at com.sun.proxy.$Proxy18.write(Unknown Source)
[junit] at cucumber.runtime.junit.JUnitReporter.write(JUnitReporter.java:71)
[junit] at cucumber.runtime.ScenarioImpl.write(ScenarioImpl.java:64)
[junit] at cucumber.steps.DBUnitHook.logScenarioStart(DBUnitHook.java:54)
[junit] at cucumber.runtime.Utils$1.call(Utils.java:34)
[junit] at cucumber.runtime.Timeout.timeout(Timeout.java:13)
[junit] at cucumber.runtime.Utils.invoke(Utils.java:30)
[junit] at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:59)
[junit] at cucumber.runtime.Runtime.runHookIfTagsMatch(Runtime.java:221)
[junit] at cucumber.runtime.Runtime.runHooks(Runtime.java:209)
[junit] at cucumber.runtime.Runtime.runBeforeHooks(Runtime.java:199)
[junit] at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
[junit] at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:83)
[junit] at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
[junit] at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
[junit] at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
[junit] at cucumber.api.junit.Cucumber.runChild(Cucumber.java:89)
[junit] at cucumber.api.junit.Cucumber.runChild(Cucumber.java:40)
[junit] at cucumber.api.junit.Cucumber.run(Cucumber.java:94)
[junit]
[junit] Testcase: | DefaultUser | allowExplicit | @{censoredLyricsJSON} | took 0 sec
This was caused by the following:
@before(order = 1)
public void logScenarioStart(Scenario scenario) {
scenario.write("Scenario: " + scenario.getName() + "\n");
}
The text was updated successfully, but these errors were encountered: