Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

a fix for the json report. #195

Closed
wants to merge 4 commits into from

4 participants

@rexhoffman

It is now less temporally bound.

rexhoffman added some commits
@rexhoffman rexhoffman removed provided scope from gherkin-deps dependency. The shade plugin
should take care of the deploying a jar/pom.xml with the runtime
dependency removed.
c82e25c
@rexhoffman rexhoffman allow the JSONReport to handle calls ordering of
step
step
match
result
match
result

or

step
match
result
step
match
result
37a6f13
@rexhoffman rexhoffman marking the pom as a snapshot as the project now contains a new bug fix
since last release
ac3b3cf
@rexhoffman rexhoffman fix for round-trip test 34274a4
@Ported

Why hasnt this pull request been merged? I am seeing the same issues.

@aslakhellesoy

@Ported because I haven't had time to test it, and it no longer applies cleanly,

@Ported

Maybe I should have phrased that better. Is there anything I can help with to get this fix merged?

I can rebase these changes against the HEAD?
And add some unit tests?

@rexhoffman
@Ported

All the version of cucumber-jvm i have used have this bug, it means that the JSON reports dont contain the results of the steps. Unless I am missing something? Our current solution is to override the version of gherkin to be 2.10.0.

I have added a test case here which demonstrates the problem:
Ported@bf8adf3

I would like to have @rexhoffman fixes in a cucumber-jvm release, can I do anything else? I am happy to write some unit tests there if you want.

@joshughes

Is there any more details on getting this merged? I would be willing to give some time to help fix whatever issues are still left.

@joshughes

I have taken some time to merge this into my own environment with cucumber-jvm. It fixes the json reporting issue with steps not having results. I merged this fix with the current master branch to ensure nothing else has effected it.

@rexhoffman

Cool. Glad to see this fixed.

@rexhoffman rexhoffman closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 9, 2012
  1. @rexhoffman

    removed provided scope from gherkin-deps dependency. The shade plugin

    rexhoffman authored
    should take care of the deploying a jar/pom.xml with the runtime
    dependency removed.
  2. @rexhoffman

    allow the JSONReport to handle calls ordering of

    rexhoffman authored
    step
    step
    match
    result
    match
    result
    
    or
    
    step
    match
    result
    step
    match
    result
  3. @rexhoffman
  4. @rexhoffman

    fix for round-trip test

    rexhoffman authored
This page is out of date. Refresh to see the latest.
View
3  java/pom.xml
@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
- <version>2.11.2</version>
+ <version>2.11.3-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Gherkin</name>
<description>Pure Java Gherkin</description>
@@ -46,7 +46,6 @@
<groupId>info.cukes</groupId>
<artifactId>gherkin-jvm-deps</artifactId>
<version>1.0.2</version>
- <scope>provided</scope>
<exclusions>
<exclusion>
<groupId>com.google.code.gson</groupId>
View
70 java/src/main/java/gherkin/formatter/JSONFormatter.java
@@ -23,8 +23,61 @@
private Map<String, Object> featureMap;
private String uri;
- private Map currentStepOrHook;
+ private enum Phase {step, match, result, embedding, output};
+
+ /**
+ * In order to handle steps being added all at once, this method determines allows methods to
+ * opperator correctly if
+ *
+ * step
+ * match
+ * result
+ * embedding
+ * output
+ * step
+ * match
+ * result
+ * embedding
+ * output
+ *
+ * or if
+ *
+ * step
+ * step
+ * match
+ * result
+ * embedding
+ * output
+ * match
+ * result
+ * embedding
+ * output
+ *
+ * is called
+ *
+ * @return the correct step for the current operation based on past method calls to the formatter interface
+ */
+ private Map getCurrentStep(Phase phase){
+ String target = phase.ordinal() <= Phase.match.ordinal()?Phase.match.name():Phase.result.name();
+ boolean lastWith = false;
+ lastWith = (phase.ordinal() > Phase.result.ordinal());
+ Map lastWithValue = null;
+ for (Map stepOrHook : getSteps()){
+ if (stepOrHook.get(target) == null){
+ if (lastWith){
+ return lastWithValue;
+ } else {
+ return stepOrHook;
+ }
+ } else {
+ lastWithValue = stepOrHook;
+ }
+ }
+ return lastWithValue;
+ }
+
+
public JSONFormatter(Appendable out) {
this.out = new NiceAppendable(out);
}
@@ -63,13 +116,12 @@ public void examples(Examples examples) {
@Override
public void step(Step step) {
- currentStepOrHook = step.toMap();
- getSteps().add(currentStepOrHook);
+ getSteps().add(step.toMap());
}
@Override
public void match(Match match) {
- currentStepOrHook.put("match", match.toMap());
+ getCurrentStep(Phase.match).put("match", match.toMap());
}
@Override
@@ -87,7 +139,7 @@ public void write(String text) {
@Override
public void result(Result result) {
- currentStepOrHook.put("result", result.toMap());
+ getCurrentStep(Phase.result).put("result", result.toMap());
}
@Override
@@ -166,19 +218,19 @@ public void syntaxError(String state, String event, List<String> legalEvents, St
}
private List<Map<String, String>> getEmbeddings() {
- List<Map<String, String>> embeddings = (List<Map<String, String>>) currentStepOrHook.get("embeddings");
+ List<Map<String, String>> embeddings = (List<Map<String, String>>) getCurrentStep(Phase.embedding).get("embeddings");
if (embeddings == null) {
embeddings = new ArrayList<Map<String, String>>();
- currentStepOrHook.put("embeddings", embeddings);
+ getCurrentStep(Phase.embedding).put("embeddings", embeddings);
}
return embeddings;
}
private List<String> getOutput() {
- List<String> output = (List<String>) currentStepOrHook.get("output");
+ List<String> output = (List<String>) getCurrentStep(Phase.output).get("output");
if (output == null) {
output = new ArrayList<String>();
- currentStepOrHook.put("output", output);
+ getCurrentStep(Phase.output).put("output", output);
}
return output;
}
Something went wrong with that request. Please try again.