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

Fixed use of formatter to list all step results in JSON output #426

Merged
merged 4 commits into from
Mar 10, 2013

Conversation

agattiker
Copy link
Contributor

No description provided.

import org.jsoup.nodes.Element;
import org.junit.Before;
import org.junit.Test;
import org.mozilla.javascript.Context;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these imports for?

@aslakhellesoy
Copy link
Contributor

If this is a fix for the JSON output, why are you chaning the JUnit formatter?
Also - please see DEVELOPERS.md about coding conventions.

@@ -95,10 +101,7 @@ public void done() {
public void result(Result result) {
testCase.results.add(result);

if (testCase.scenario != null && testCase.results.size() == testCase.steps.size()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relies on steps and results to grow in parallel.

@agattiker
Copy link
Contributor Author

Sorry about the format and import issues, fixed now.

I had to change the JUnit formatter because it relied on test case steps and results lists to grow in parallel. I changed this behavior so that first all steps are run, then they are formatted.

@thestumonkey
Copy link

Firstly, your test JSON file only works in linux environment. In windows environment the uri looks like this:
"uri": "cucumber\runtime\formatter\JSONPrettyFormatterTest.feature"

Also, I am using your fix on my project and I'm getting an index out of bounds exception every time it tries to write a result
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.remove(ArrayList.java:387)
at gherkin.formatter.PrettyFormatter.indentedLocation(PrettyFormatter.java:142)
at gherkin.formatter.PrettyFormatter.printStep(PrettyFormatter.java:255)
at gherkin.formatter.PrettyFormatter.result(PrettyFormatter.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

This was referenced Dec 14, 2012
@priceand
Copy link

Im confused as to whether or not this is fixed and how to get the fix into our repo ? Does the JUnit formatter need changing ? It is the JSON output files that I think are wrong thats showing my givens as
Result was missing for this step ?

@aslakhellesoy
Copy link
Contributor

@priceand It's not merged to the cucumber repo's master branch if that's what you're asking. When it is this PR will be closed. This is unrelated to the JUnit report.

I've been too busy to look into this, hoping to get some time during holidays.

@priceand
Copy link

Ok thanks!

Andy

From: Aslak Hellesøy [mailto:notifications@github.com]
Sent: 17 December 2012 15:01
To: cucumber/cucumber-jvm
Cc: Price, Andrew M
Subject: Re: [cucumber-jvm] Fixed use of formatter to list all step results in JSON output (#426)

@priceandhttps://github.com/priceand It's not merged to the cucumber repo's master branch if that's what you're asking. When it is this PR will be closed. This is unrelated to the JUnit report.

I've been too busy to look into this, hoping to get some time during holidays.


Reply to this email directly or view it on GitHubhttps://github.com//pull/426#issuecomment-11444765.


This message, and any attachments, is for the intended recipient(s) only, may contain information that is privileged, confidential and/or proprietary and subject to important terms and conditions available at http://www.bankofamerica.com/emaildisclaimer. If you are not the intended recipient, please delete this message.

@kingsleyh
Copy link

This fix will be very much appreciated as I rely on the json report for the jenkins cucumber report plugin: https://github.com/masterthought/jenkins-cucumber-jvm-reports-plugin-java

Currently all json reports after cucumber-jvm 1.0.8 do not produce the required result sections consistently in the json report which means the result of the step cannot be determined. The plugin currently has thousands of downloads which means I get lots of questions about this and am looking forward to seeing this resolved :)

@poum
Copy link

poum commented Dec 21, 2012

So does my javascript formatter: https://github.com/poum/cucumber-json2report. But I'm pretty far of Kingsleyh download rate (euphemism).

So I wish you having soon holydays (for the work already done, not for the fix of course .... the price of glory ;-)

@agattiker
Copy link
Contributor Author

@thestumonkey, I committed a fix for Windows OS. But I don't know how to reproduce your java.lang.IndexOutOfBoundsException, could you investigate? I haven't touched that part of the code, are you sure your issue is related to this pull request?

@thestumonkey
Copy link

Confirmed your test now passes.

I'm unsure quite how to check if this issue is due to your pull request, but I'm using the latest dev branch then putting your code on top. It could be the way I'm building it and referencing it, I'm still fairly new to this stuff. Any idea when we can expect this making it into the main branch?

@priceand
Copy link

So is there a fix now ? How can I get it into my code ???!!

2 similar comments
@priceand
Copy link

So is there a fix now ? How can I get it into my code ???!!

@priceand
Copy link

So is there a fix now ? How can I get it into my code ???!!

@thestumonkey
Copy link

Any update on this pull request?

@maximilian-novikov-db
Copy link

Hi, any updates on this?
We use jenkins-cucumber-jvm-reports-plugin-java and after upgrade to cucumber-jvm 1.1.1 reports are broken.

@DiegoBallve
Copy link

Anxiously waiting for this one too.

@thestumonkey
Copy link

So I did the following:

git clone , then set agattiker's repo as a remote. I then fetched the repo with the JSON-Format-Fix branch and ran maven. One of the tests failed:
git clone git://github.com/cucumber/cucumber-jvm.git
git remote add jsonfix git://github.com/agattiker/cucumber-jvm.git
fetch jsonfix
git merge jsonfix/json-format-fix

git clean install

Failed tests: featureWithOutlineTest(cucumber.runtime.formatter.JSONPrettyForm
(..)rTest): expected:<[[

So I compiled with -D skipTests.

Now when I run my project with the updated libraries I get:

Exception in thread "main" java.lang.NoSuchMethodError: org.junit.runner.Description.createSuiteDescription(Ljava/lang/String;Ljava/io/Serializable;[Ljava/lang/annotation/Annotation;)Lorg/junit/runner/Description;
at cucumber.runtime.junit.FeatureRunner.getDescription(FeatureRunner.java:43)
at cucumber.api.junit.Cucumber.describeChild(Cucumber.java:72)
at cucumber.api.junit.Cucumber.describeChild(Cucumber.java:37)
at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:290)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:45)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Am I doing something wrong or is there an issue with this code?

@aslakhellesoy
Copy link
Contributor

On Wed, Jan 30, 2013 at 9:28 AM, Stuart Alexander
notifications@github.comwrote:

So I did the following:

git clone , then set agattiker's repo as a remote. I then fetched the repo
with the JSON-Format-Fix branch and ran maven. One of the tests failed:
git clone git://github.com/cucumber/cucumber-jvm.git
git remote add jsonfix git://github.com/agattiker/cucumber-jvm.git
fetch jsonfix
git merge jsonfix/json-format-fix

git clean install

Failed tests:
featureWithOutlineTest(cucumber.runtime.formatter.JSONPrettyForm
(..)rTest): expected:<[[

So I compiled with -D skipTests.

Now when I run my project with the updated libraries I get:

Exception in thread "main" java.lang.NoSuchMethodError:
org.junit.runner.Description.createSuiteDescription(Ljava/lang/String;Ljava/io/Serializable;[Ljava/lang/annotation/Annotation;)Lorg/junit/runner/Description;
at
cucumber.runtime.junit.FeatureRunner.getDescription(FeatureRunner.java:43)
at cucumber.api.junit.Cucumber.describeChild(Cucumber.java:72)
at cucumber.api.junit.Cucumber.describeChild(Cucumber.java:37)
at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:290)
at
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:45)
at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Am I doing something wrong or is there an issue with this code?

Cucumber-JVM's master branch depends on JUnit 4.11, which defines a new
org.junit.runner.Description.createSuiteDescription method that
Cucumber-JVM uses. This method doesn't exist in previous versions of JUnit.

The exception indicates that you have an older version of JUnit on the
CLASSPATH.

Aslak


Reply to this email directly or view it on GitHubhttps://github.com//pull/426#issuecomment-12881110.

@thestumonkey
Copy link

That's what my research showed me, but I have

junit
junit
4.11

in my POM.

I think I have solved this, I don't think the new JAR's were in my maven repo, despite me telling it to use a local one. However, after getting the test running, I am still getting my original "out of bounds" exception, detailed above.

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.remove(ArrayList.java:387)
at gherkin.formatter.PrettyFormatter.indentedLocation(PrettyFormatter.java:142)
at gherkin.formatter.PrettyFormatter.printStep(PrettyFormatter.java:255)
at gherkin.formatter.PrettyFormatter.result(PrettyFormatter.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at cucumber.runtime.Utils$1.call(Utils.java:42)
at cucumber.runtime.Timeout.timeout(Timeout.java:12)
at cucumber.runtime.Utils.invoke(Utils.java:38)
at cucumber.runtime.RuntimeOptions$2.invoke(RuntimeOptions.java:136)
at $Proxy14.result(Unknown Source)
at cucumber.runtime.junit.JUnitReporter.result(JUnitReporter.java:97)
at cucumber.runtime.Runtime.runStep(Runtime.java:276)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:48)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:42)
at cucumber.runtime.model.CucumberScenario.runBackground(CucumberScenario.java:45)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:34)
at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:76)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:65)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:20)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:72)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:77)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:37)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at cucumber.api.junit.Cucumber.run(Cucumber.java:82)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

I am unsure if this is me merging the branches and building incorrectly or if there's an error in the pull request code. Any chance you could merge this and release an update into maven? :)

@aslakhellesoy
Copy link
Contributor

On Wed, Jan 30, 2013 at 11:05 AM, Stuart Alexander <notifications@github.com

wrote:

That's what my research showed me, but I have

junit
junit
4.11

in my POM.

Try mvn dependency:tree

Some of your other deps may depend on an old junit, in which case you
should it.

I think I have solved this, I don't think the new JAR's were in my maven
repo, despite me telling it to use a local one. However, after getting the
test running, I am still getting my original "out of bounds" exception,
detailed above.

Please file a bug report for that issue, with details about how it can be
reproduced.

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.remove(ArrayList.java:387)
at
gherkin.formatter.PrettyFormatter.indentedLocation(PrettyFormatter.java:142)
at gherkin.formatter.PrettyFormatter.printStep(PrettyFormatter.java:255)
at gherkin.formatter.PrettyFormatter.result(PrettyFormatter.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at cucumber.runtime.Utils$1.call(Utils.java:42)
at cucumber.runtime.Timeout.timeout(Timeout.java:12)
at cucumber.runtime.Utils.invoke(Utils.java:38)
at cucumber.runtime.RuntimeOptions$2.invoke(RuntimeOptions.java:136)
at $Proxy14.result(Unknown Source)
at cucumber.runtime.junit.JUnitReporter.result(JUnitReporter.java:97)
at cucumber.runtime.Runtime.runStep(Runtime.java:276)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:48)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:42)
at
cucumber.runtime.model.CucumberScenario.runBackground(CucumberScenario.java:45)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:34)
at
cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:76)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:65)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:20)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:72)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:77)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:37)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at cucumber.api.junit.Cucumber.run(Cucumber.java:82)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)

at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

I am unsure if this is me merging the branches and building incorrectly or
if there's an error in the pull request code. Any chance you could merge
this and release an update into maven? :)


Reply to this email directly or view it on GitHubhttps://github.com//pull/426#issuecomment-12884612.

@aslakhellesoy aslakhellesoy merged commit cf7ed05 into cucumber:master Mar 10, 2013
@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

Successfully merging this pull request may close these issues.

8 participants