Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Gherkin Json formatter does not include a result for scenario outlines #165

Closed
josephwilk opened this issue Feb 23, 2012 · 72 comments
Closed
Labels

Comments

@josephwilk
Copy link
Contributor

Gherkin 2.9.0.
I'll add some concrete examples to this but I suspect that the JSON formatter does not output the result for scenario outlines.

For scenarios we get:

{"steps"=>[{"result"=>{"status"=>"passed"}, .....,  "type"=>"scenario", "description"=>"", "keyword"=>"Scenario"}

Where result indicates the step passed.

For scenario outlines:

{"examples"=>[{"name"=>"", "line"=>114}], ....}

There is nothing about the status of the examples/rows/cells.

@jasonmci
Copy link

Confirming issue in 2.10.0

@aslakhellesoy
Copy link
Contributor

I'll reopen this issue when someone provides some code that reproduces this claimed (mis)behaviour?

@cpatel
Copy link

cpatel commented Jul 13, 2012

I am able to reproduce this cucumber-jvm 1.0-9 (not sure which gherkin build it picks up as depdendency).

With cucumber-jvm-1.0-8, I am observing that json reports has "result" reported for each step. But with cucumber-jvm-1.0-9:, json reports has "result" reported only for last step. This is for both "Scenario" and "Scenario Outline".

Feature file is very straight forward:

@WIP
Feature: Add two numbers

Scenario Outline: Add two numebrs
  Given two numbers <number_1> and <number_2>
  When I add them
  Then Result is <number_3>

  Examples:
    |number_1|number_2|number_3|
    |2       |3       |5       |
    |1       |2       |3       |

Scenario: Add two numebrs
   Given two numbers 1 and 1
   When I add them
   Then Result is 2

JSON with cucumber-jvm-1.0-8:

{
        "id": "add-two-numbers;add-two-numebrs;;2",
        "tags": [
          {
            "name": "@WIP",
            "line": 1
          }
        ],
        "description": "",
        "name": "Add two numebrs",
        "keyword": "Scenario Outline",
        "line": 11,
        "steps": [
          {
            "result": {
              "duration": 130673000,
              "status": "passed"
            },
            "name": "two numbers 2 and 3",
            "keyword": "Given ",
            "line": 5,
            "match": {
              "arguments": [
                {
                  "val": "2",
                  "offset": 12
                },
                {
                  "val": "3",
                  "offset": 18
                }
              ],
              "location": "AddNumbersSteps.initializeNumbers(int,int)"
            },
            "matchedColumns": [
              0,
              1
            ]
          },
          {
            "result": {
              "duration": 776000,
              "status": "passed"
            },
            "name": "I add them",
            "keyword": "When ",
            "line": 6,
            "match": {
              "location": "AddNumbersSteps.add()"
            }
          },
          {
            "result": {
              "duration": 2300000,
              "status": "passed"
            },
            "name": "Result is 5",
            "keyword": "Then ",
            "line": 7,
            "match": {
              "arguments": [
                {
                  "val": "5",
                  "offset": 10
                }
              ],
              "location": "AddNumbersSteps.result(int)"
            },
            "matchedColumns": [
              2
            ]
          }
        ],
        "type": "scenario"
      },

JSON with cucumber-jvm-1.0-9:

{
        "id": "add-two-numbers;add-two-numebrs;;2",
        "tags": [
          {
            "name": "@WIP",
            "line": 1
          }
        ],
        "description": "",
        "name": "Add two numebrs",
        "keyword": "Scenario Outline",
        "line": 11,
        "steps": [
          {
            "name": "two numbers 2 and 3",
            "keyword": "Given ",
            "line": 5,
            "matchedColumns": [
              0,
              1
            ]
          },
          {
            "name": "I add them",
            "keyword": "When ",
            "line": 6
          },
          {
            "result": {
              "duration": 2992000,
              "status": "passed"
            },
            "name": "Result is 5",
            "keyword": "Then ",
            "line": 7,
            "match": {
              "arguments": [
                {
                  "val": "5",
                  "offset": 10
                }
              ],
              "location": "AddNumbersSteps.result(int)"
            },
            "matchedColumns": [
              2
            ]
          }
        ],
        "type": "scenario"

I am just guessing problem might be in this commit in JSONFormatter.java.
cucumber/gherkin@d03a593#java/src/main/java/gherkin/formatter/JSONFormatter.java

Let me know if you need anything else.

Thanks,
-Chirag

@cpatel
Copy link

cpatel commented Jul 13, 2012

Oops sorry for weird formatting...did not expect to come out this way...hope you can read it...

@aslakhellesoy
Copy link
Contributor

I fixed the formatting. Reopening since there is now a way to reproduce this.

@rexhoffman
Copy link

Very timely. Just ran in to this working on master thought's jenkins/maven json report interpreter. I have a pull request with a full maven project being run as a maven-invoker-test in his plugin (junit->cucumber-jvm->json report-> interpreter plugin) I can add similar tests anywhere you might like them in cucumber-jvm. I'm targeting the this because the JSON formatter will be simple to make thread safe, and the plugin will be simple to extend and configure to break builds on some configurable number of work in progress @tags, number of steps throwing pending exceptions, number of features w/ pending exceptions, etc.

@rlishtaba
Copy link

Fixed in which version? I still have this bug in v2.11.1

@rexhoffman
Copy link

I have a fix in my pending change list to gherkin. I also added tests in a pending change to cucumber-jvm.

So, not just yet.

@cpatel
Copy link

cpatel commented Sep 13, 2012

Did this fix ever get committed? Still waiting on this. Thanks

@fcbeyer
Copy link
Contributor

fcbeyer commented Sep 27, 2012

I too am experiencing this issue

@szydan
Copy link

szydan commented Oct 1, 2012

Hi any update on this - we've just installed jenkis plugin and discovered this.
We use cucumber-jvm 1.0.14

@aslakhellesoy
Copy link
Contributor

I started working on it on a branch, but nothing finished yet. Hang in there.

@marjohr
Copy link

marjohr commented Oct 4, 2012

Glad to hear! Really appreciate this awesome tool!

@fcbeyer
Copy link
Contributor

fcbeyer commented Oct 6, 2012

can the duration be captured in the result when making the fix?

@scampi
Copy link

scampi commented Oct 8, 2012

Hi, that would be really great to have this fix!

@silvioluiz
Copy link

I was almost disappointed thinking that the cucumber-reporting was not working. It really only works with this fix.

@vijayeta2387
Copy link

Is there any update on the Issue #350 that in the JSON report it gives "Result was missing for this step" for all the steps except the last step of the scenario.

@aslakhellesoy
Copy link
Contributor

In order to make a clean fix for this I want to make a big refactoring to gherkin. It might take a while. I'll report here when there is progress.

@mattwynne
Copy link
Contributor

Sounds interesting @aslakhellesoy. Care to elaborate?

@brian-preston-nominum
Copy link

I'm pretty excited for your fix @aslakhellesoy !

@adamark
Copy link

adamark commented Oct 31, 2012

Looking forward to your fix @aslakhellesoy !

@navinjd
Copy link

navinjd commented Nov 8, 2012

When can we expect this fix available? Anxiously waiting for it as this has become a major issue for us.

@Luxor
Copy link

Luxor commented Nov 8, 2012

Agree. This is major issue for me as well. Looking forward to the fix.

@ayoseg
Copy link

ayoseg commented Nov 26, 2012

@aslakhellesoy ..... I know you are very busy and you have been very helpful when it comes to answering questions online about JVM Cucumber. Thanks for that.

Do you know when you 'd make and commit the fix ?

I am using Cucumber JVM 1.1.1, are there any drawbacks of going back to JVM 1.0.8 ?

@aslakhellesoy
Copy link
Contributor

I don't know when I'll have time to fix this. Both work and private life demands a lot of my time, and I tend to do open source work whenever I get a free evening or two. When this happens is so hard to predict that I'd rather not say.

You can assess the drawbacks of downgrading yourself by examining History.md in gherkin and cucumber-jvm.

@ayoseg
Copy link

ayoseg commented Nov 26, 2012

Ok, thank you sir. We look forward to having a fix in the near future

@brasmusson
Copy link
Contributor

@AbezarBaker If you get the java.lang.NoClassDefFoundError: junit/framework/JUnit4TestAdapterCache error, it seems that fork="yes works better.

This modified Ant file for the examples/java-helloworld works for me:

> ant download runcukes-junit

@AbezarBaker
Copy link

@brasmusson Hi,some success i was able to kick of my test using junit runner with the help of your ANT junit snippet and the JSON result was correct! YooHoo!.

Problem is that it runs with some hardcoded cucmebr options in my runner class as shown above

@CucumberOptions( features = "release/features/Briefcase",//path to the features
format = {"pretty", "html:target/cucumber-html-report", "json:target/integration_cucumber.json"},
tags = {"@Briefcase"})

If i want to override these by passing them from the ANT file to the runner class then do i need to remove the lines above from the runner class or it will just over look it?

Right now im stuck trying to pass the cucmber options from ANT junit task.Below is my code

                   <junit failureproperty="cucumber.exitstatus" fork="yes" forkmode="once>
        <classpath refid="build.classpath"/>

        <jvmarg value="-Dcucumber.option=--glue ${features.dir}/${Features}" />
        <jvmarg value="-Dcucumber.option=--tags ${Tags}" />
        <jvmarg value="-Dcucumber.options=--format json:target/cucumber.json"/>
        <test name="com.qa.selenium.bdd.stepdefs.GenericRunner" haltonfailure="no">
          <formatter type="plain" usefile="false"/>
        </test>
            </junit>

Even though i am trying to set the cucumber options above ,the test runs with the options in the runner class.Any ideas if my code to pass the cucumber options is correct ?Appreciate your help!

When i remove the cucmber options in the runner class i get the run output below.Seem like the glue parameter is being ignored

[junit] Testsuite: com.tr.qa.selenium.bdd.stepdefs.GenericRunner
[junit] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec
[junit] ------------- Standard Output ---------------
[junit] No features found at [classpath:com/tr/qa/selenium/bdd/stepdefs]
[junit]
[junit]
[junit] 0 Scenarios
[junit] 0 Steps
[junit] 0m0.000s
[junit]
[junit] ------------- ---------------- ---------------

@brasmusson
Copy link
Contributor

@AbezarBaker A couple of things. The two first jvmarg uses -Dcucumber.option= instead of -Dcucumber.options= (ending with an 's'), on the other hand you can only define -Dcucumber.options= in one jvmarg. The jvmarg for the --glue parameter does also use the feature directory instead of a glue package. Looking on the snippet from your previous ant file snippet, the jvmarg you want is something like:

  <jvmarg value="-Dcucumber.options=${features.dir}/${Features} --glue com.tr.qa.selenium.bdd.stepdefs --tags ${Tags} --format json:target/cucumber.json" />

@AbezarBaker
Copy link

@brasmusson the typo and the line of code you suggested above did the trick.Thanks a lot for your help!!
One more question do i need to remove the lines from the runner class below since i am overriding them via the jvmarg in junit ant task or it will just over look it?

@RunWith(Cucumber.class)
@CucumberOptions( features = "release/features/Briefcase",//path to the features
format = {"pretty", "html:target/cucumber-html-report", "json:target/integration_cucumber.json"},
tags = {"@Briefcase"})

public class GenericRunner {

}

The reason i ask is because if i leave the cucumber options annotation in the runner class then after the junit runner runs,in the target folder i see two sets of reports

(https://f.cloud.github.com/assets/6143899/2241336/36fbfb24-9ccc-11e3-9fb7-d04f9c3fbe8d.png)

@CrazyRyu
Copy link

Just wanted to say that I also get the "Step is missing Result:..." when using "Scenario Outline:" but in my case I use TestNG in combination with Cucumber.
Getting that problem with 1.1.5 and 1.1.6-SNAPSHOT.

Should I create a new issue for that special case with TestNG or comment here?

@brasmusson
Copy link
Contributor

@AbezarBaker The values in the jvmag will be used instead of the values in the @CucumberOptions, except in the case of formatters. It shouldn't be that way, but that issue has not been fixed yet (cucumber/cucumber-jvm#643). To avoid two sets of report, you currently need to remove the format parameter from the @CucumberOptions. If you are always using Ant and sending parameters with jvmag, the @CucumberOptions could be removed altogether.

@AbezarBaker
Copy link

@brasmusson thanks for the information .Cheers!

@akellett
Copy link

akellett commented Mar 4, 2014

Using Ruby Cucumber. Following the thread it appears there is a Cucumber-JVM fix. Is there a plan or recipe whereby the fix can be made available to the Ruby community? Within Jenkins this eliminates the ability to use the standard Cucumber reporting plugins.

Work around is a custom .feature file processor to turn scenario outline pattern into basic scenarios.

@ShoopIndy
Copy link

@akellet, good idea. Do you have a custom .feature file processor that you could share?

blt04 referenced this issue in blt04/cucumber-reporting Mar 13, 2014
Sometimes the json formatter does not include results in step
elements of a Scenario Outline.
For example, see: cucumber/gherkin#165

This caused an NPE when generating reports:

    org.apache.velocity.exception.MethodInvocationException: Invocation of
    method 'getName' in class net.masterthought.cucumber.json.Step threw
    exception java.lang.NullPointerException at
    templates/featureReport.vm[line 210, column 25]

This looks like a regression introduced in 906b9b9.
@faraazkhan
Copy link

+1 for fix on Ruby Cucumber.

@Chuckv
Copy link

Chuckv commented Mar 26, 2014

Also looking for a fix for this in Ruby Cucumber

@blt04
Copy link

blt04 commented Mar 30, 2014

For anyone who wants a quick-and-dirty way to get cucumber reporting to report the results for outlines, we've been using this with some success:
https://gist.github.com/blt04/9866357

It basically converts each row of a scenario outline into a regular scenario in the JSON output. Not perfect, but works for us!

@FrostbittenKing
Copy link

Thx for this workaround @blt04. I seriously needed something like that, since nobody bothered to fix this for the last two years (srsly wtf), yeah I know it was fixed for java, but not ruby, bleh.

@nbollepalli
Copy link

Thank you for this workaround @blt04. This really saved me lot of time. Appreciate it!

@DoubleJ2011
Copy link

@blt04 Appreciate for this support, while one issue during i use the json_expanded_formatter.rb is:
*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansicon/) to get coloured output on Windows
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:18: warning: class variable access from toplevel
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:19: warning: class variable access from toplevel
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:21: warning: class variable access from toplevel
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:22: warning: class variable access from toplevel
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:24: warning: already initialized constant ServerPort
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:25: warning: already initialized constant TestServerPort
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:30: warning: class variable access from toplevel
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:31: warning: class variable access from toplevel
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:24: warning: already initialized constant ServerPort
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:25: warning: already initialized constant TestServerPort
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:30: warning: class variable access from toplevel
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:31: warning: class variable access from toplevel
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:24: warning: already initialized constant ServerPort
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:25: warning: already initialized constant TestServerPort
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:30: warning: class variable access from toplevel
D:/JenkinsRun_Integration/features/support/app_installation_hooks.rb:31: warning: class variable access from toplevel
uninitialized constant Cucumber::Formatter::JsonExpanded
Error creating formatter: Cucumber::Formatter::JsonExpanded (NameError)
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.14/lib/cucumber/constantize.rb:40:in constantize_name' C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.14/lib/cucumber/constantize.rb:13:inblock in constantize'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.14/lib/cucumber/constantize.rb:12:in each' C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.14/lib/cucumber/constantize.rb:12:inconstantize'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.14/lib/cucumber/cli/configuration.rb:83:in formatter_class' C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.14/lib/cucumber/cli/configuration.rb:182:inblock in formatters'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.14/lib/cucumber/cli/configuration.rb:178:in map' C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.14/lib/cucumber/cli/configuration.rb:178:informatters'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.14/lib/cucumber/cli/configuration.rb:76:in build_tree_walker' C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.14/lib/cucumber/runtime.rb:46:inrun!'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.14/lib/cucumber/cli/main.rb:47:in execute!' C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.14/bin/cucumber:13:in<top (required)>'
C:/Ruby193/bin/cucumber:23:in load' C:/Ruby193/bin/cucumber:23:in

'

I use cucumber version is 1.3.14
Change the rb file name to json_expanded.rb and place it under cucumber-1.3.14\lib\cucumber\formatter\

anything i do wrong? waiting online.

@aslakhellesoy
Copy link
Contributor

@DoubleJ2011 your question is unrelated to this bug report. Please ask general questions on the cukes google group.

@DoubleJ2011
Copy link

@aslakhellesoy actually my question is the same
as the topic: why no result in json report if use scenario outline with cucumber ruby. while seems no answer yet. try hack method which @blt04 mentioned meet error which I said above, so want to know how to use it. it is urgent for me to get correct result in json when I use scenario outline. thanks

@aslakhellesoy
Copy link
Contributor

@DoubleJ2011 Oh yes I see that now. You included so much unrelated output (ANSICON, class variable access warning) that I thought that's what you meant. Please only include relevant info, and format your code/logs so it's readable please.

@DoubleJ2011
Copy link

oh, sorry for my mistaken. take care next time and expect to the fix of the issue thank you

来自 MEIZU MX

-------- 原始邮件 --------
发件人:Aslak Hellesøy notifications@github.com
时间:周四 6月26日 21:23
收件人:cucumber/gherkin gherkin@noreply.github.com
抄送:DoubleJ2011 yujiajia1986@gmail.com
主题:Re: [gherkin] Gherkin Json formatter does not include a result for scenario outlines (#165)

@DoubleJ2011 Oh yes I see that now. You included so much unrelated output (ANSICON, class variable access warning) that I thought that's what you meant. Please only include relevant info, and format your code/logs so it's readable please.


Reply to this email directly or view it on GitHub:
cucumber/gherkin#165 (comment)

@brasmusson
Copy link
Contributor

@akellett @ShoopIndy @faraazkhan @Chuckv @blt04 @FrostbittenKing @nbollepalli @DoubleJ2011 FYI, cucumber version 2.0.0.beta.1 will produce json files compatible with the cucumber reporting tools when using the --expand option.

@icloudphil
Copy link

Is there a javascript version of this fix as well?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests