Skip to content
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 when calling Scenario.write in before hook to JSONFormatter #638

Closed
K76154 opened this issue Nov 26, 2013 · 4 comments

Comments

@K76154
Copy link
Contributor

K76154 commented Nov 26, 2013

I have a before hook, and I do something in it, including writing something into the reporters. I have no problem writing to HTML and JUnit reports, but for JSON report, I have the following exception:

11-26 23:19:03.980: V/Unknown Source(29862): java.lang.NullPointerException
11-26 23:19:03.980: V/Unknown Source(29862): at gherkin.formatter.JSONFormatter.getSteps(JSONFormatter.java:235)
11-26 23:19:03.980: V/Unknown Source(29862): at gherkin.formatter.JSONFormatter.getCurrentStep(JSONFormatter.java:65)
11-26 23:19:03.980: V/Unknown Source(29862): at gherkin.formatter.JSONFormatter.getOutput(JSONFormatter.java:253)
11-26 23:19:03.980: V/Unknown Source(29862): at gherkin.formatter.JSONFormatter.write(JSONFormatter.java:136)
11-26 23:19:03.980: V/Unknown Source(29862): at java.lang.reflect.Method.invokeNative(Native Method)
11-26 23:19:03.980: V/Unknown Source(29862): at java.lang.reflect.Method.invoke(Method.java:511)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Utils$1.call(Utils.java:35)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Timeout.timeout(Timeout.java:12)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Utils.invoke(Utils.java:31)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.RuntimeOptions$2.invoke(RuntimeOptions.java:178)
11-26 23:19:03.980: V/Unknown Source(29862): at $Proxy7.write(Native Method)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.ScenarioImpl.write(ScenarioImpl.java:62)
11-26 23:19:03.980: V/Unknown Source(29862): at com.lotus.sync.traveler.test.common.TestLogger.writeToScenario(TestLogger.java:525)
11-26 23:19:03.980: V/Unknown Source(29862): at com.lotus.sync.traveler.test.common.TestLogger.log(TestLogger.java:469)
11-26 23:19:03.980: V/Unknown Source(29862): at com.lotus.sync.traveler.test.common.TestLogger.log(TestLogger.java:408)
11-26 23:19:03.980: V/Unknown Source(29862): at com.lotus.sync.traveler.test.common.TestLogger.info(TestLogger.java:207)
11-26 23:19:03.980: V/Unknown Source(29862): at com.lotus.sync.traveler.test.steps.SharedDependencies.before(SharedDependencies.java:126)
11-26 23:19:03.980: V/Unknown Source(29862): at java.lang.reflect.Method.invokeNative(Native Method)
11-26 23:19:03.980: V/Unknown Source(29862): at java.lang.reflect.Method.invoke(Method.java:511)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Utils$1.call(Utils.java:35)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Timeout.timeout(Timeout.java:12)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Utils.invoke(Utils.java:31)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:59)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Runtime.runHookIfTagsMatch(Runtime.java:221)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Runtime.runHooks(Runtime.java:209)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Runtime.runBeforeHooks(Runtime.java:199)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:41)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:116)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.api.android.CucumberInstrumentation.onStart(CucumberInstrumentation.java:175)
11-26 23:19:03.980: V/Unknown Source(29862): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1619)
11-26 23:19:03.980: V/Unknown Source(29862): java.lang.NullPointerException
11-26 23:19:03.980: V/Unknown Source(29862): at gherkin.formatter.JSONFormatter.getSteps(JSONFormatter.java:235)
11-26 23:19:03.980: V/Unknown Source(29862): at gherkin.formatter.JSONFormatter.getCurrentStep(JSONFormatter.java:65)
11-26 23:19:03.980: V/Unknown Source(29862): at gherkin.formatter.JSONFormatter.getOutput(JSONFormatter.java:253)
11-26 23:19:03.980: V/Unknown Source(29862): at gherkin.formatter.JSONFormatter.write(JSONFormatter.java:136)
11-26 23:19:03.980: V/Unknown Source(29862): at java.lang.reflect.Method.invokeNative(Native Method)
11-26 23:19:03.980: V/Unknown Source(29862): at java.lang.reflect.Method.invoke(Method.java:511)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Utils$1.call(Utils.java:35)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Timeout.timeout(Timeout.java:12)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Utils.invoke(Utils.java:31)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.RuntimeOptions$2.invoke(RuntimeOptions.java:178)
11-26 23:19:03.980: V/Unknown Source(29862): at $Proxy7.write(Native Method)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.ScenarioImpl.write(ScenarioImpl.java:62)
11-26 23:19:03.980: V/Unknown Source(29862): at com.lotus.sync.traveler.test.common.TestLogger.writeToScenario(TestLogger.java:525)
11-26 23:19:03.980: V/Unknown Source(29862): at com.lotus.sync.traveler.test.common.TestLogger.log(TestLogger.java:469)
11-26 23:19:03.980: V/Unknown Source(29862): at com.lotus.sync.traveler.test.common.TestLogger.log(TestLogger.java:408)
11-26 23:19:03.980: V/Unknown Source(29862): at com.lotus.sync.traveler.test.common.TestLogger.info(TestLogger.java:207)
11-26 23:19:03.980: V/Unknown Source(29862): at com.lotus.sync.traveler.test.steps.SharedDependencies.before(SharedDependencies.java:126)
11-26 23:19:03.980: V/Unknown Source(29862): at java.lang.reflect.Method.invokeNative(Native Method)
11-26 23:19:03.980: V/Unknown Source(29862): at java.lang.reflect.Method.invoke(Method.java:511)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Utils$1.call(Utils.java:35)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Timeout.timeout(Timeout.java:12)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Utils.invoke(Utils.java:31)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:59)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Runtime.runHookIfTagsMatch(Runtime.java:221)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Runtime.runHooks(Runtime.java:209)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.Runtime.runBeforeHooks(Runtime.java:199)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:41)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:116)
11-26 23:19:03.980: V/Unknown Source(29862): at cucumber.api.android.CucumberInstrumentation.onStart(CucumberInstrumentation.java:175)
11-26 23:19:03.980: V/Unknown Source(29862): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1619)

@ankigure22
Copy link

Hi
When we can expect a fix for that problem as I would like to use scenario.write under @before method for my project.
Thanks

@lunivore
Copy link

Hi @K76154 and @ankigure22 , sorry that nobody was able to get to this at the time! The codebase has moved on significantly, and I believe your problem has been fixed by now, so I'm closing this ticket. If this is still an issue for you, please could you submit a new report with an up-to-date stack trace? Thanks!

@brasmusson
Copy link
Contributor

This is a duplicate of #701, now when Cucumber-JVM has been upgraded to use Gherkin v4 - available as 2.0.0-SNAPSHOT (with the groupId io.cucumber), the Json Formatter handles writes from before hooks correctly.

@lock
Copy link

lock bot commented Oct 25, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants