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

Different location objects in json report. #945

Closed
tommywo opened this issue Jan 27, 2016 · 5 comments · Fixed by #949
Closed

Different location objects in json report. #945

tommywo opened this issue Jan 27, 2016 · 5 comments · Fixed by #949

Comments

@tommywo
Copy link

tommywo commented Jan 27, 2016

When i use after step from another gem,
location element of after step in json report is different then in other steps


              "location": {
                "filepath": {
                  "filename": "json_spec-1.1.4/lib/json_spec/cucumber.rb"
                },
                "lines": {
                  "data": [
                    "5"
                    ]
                  }
                }

I would expect it to be:

 "location": "json_spec-1.1.4/lib/json_spec/cucumber.rb:5"

full json:

[
  {
    "uri": "features/selenium.feature",
    "id": "test",
    "keyword": "Feature",
    "name": "test",
    "description": "",
    "line": 1,
    "elements": [
      {
        "id": "test;test1",
        "keyword": "Scenario",
        "name": "test1",
        "description": "",
        "line": 2,
        "type": "scenario",
        "steps": [
          {
            "keyword": "Given ",
            "name": "We are using selenium to test with chrome",
            "line": 3,
            "match": {
              "location": "features/step_definitions/selenium/selenium.rb:8"
            },
            "result": {
              "status": "passed",
              "duration": 1717150000
            }
          },
          {
            "keyword": "When ",
            "name": "I navigate to \"http://www.google.com\"",
            "line": 4,
            "match": {
              "location": "selenium-cucumber-2.1.3/lib/selenium-cucumber/navigation_steps.rb:3"
            },
            "result": {
              "status": "passed",
              "duration": 1371137000
            }
          },
          {
            "keyword": "Then ",
            "name": "I should see page title as \"Google\"",
            "line": 5,
            "match": {
              "location": "selenium-cucumber-2.1.3/lib/selenium-cucumber/assertion_steps.rb:4"
            },
            "result": {
              "status": "passed",
              "duration": 11001000
            }
          },
          {
            "keyword": "And ",
            "name": "element having id \"lst-ib\" should be enabled",
            "line": 6,
            "match": {
              "location": "selenium-cucumber-2.1.3/lib/selenium-cucumber/assertion_steps.rb:31"
            },
            "result": {
              "status": "passed",
              "duration": 33003000
            }
          },
          {
            "keyword": "When ",
            "name": "I enter \"hello world\" into input field having id \"lst-ib\"",
            "line": 7,
            "match": {
              "location": "selenium-cucumber-2.1.3/lib/selenium-cucumber/input_steps.rb:4"
            },
            "result": {
              "status": "passed",
              "duration": 82008000
            }
          },
          {
            "keyword": "And ",
            "name": "I click on element having id \"lst-ib\"",
            "line": 8,
            "match": {
              "location": "selenium-cucumber-2.1.3/lib/selenium-cucumber/click_elements_steps.rb:4"
            },
            "result": {
              "status": "passed",
              "duration": 43005000
            }
          }
        ],
        "after": [
          {
            "match": {
              "location": {
                "filepath": {
                  "filename": "json_spec-1.1.4/lib/json_spec/cucumber.rb"
                },
                "lines": {
                  "data": [
                    "5"
                  ]
                }
              }
            },
            "result": {
              "status": "passed",
              "duration": 0
            }
          }
        ]
      }
    ]
  }
]

cucumber-ruby 1.4.3
selenium-cucumber 2.1.4
cucumber 2.3.2

@larryprice
Copy link

I'm having a very similar issue in my "Before" hook:

"before": [{
  "match": {
    "location": {
      "file": "capybara-2.6.2/lib/capybara/cucumber.rb",
      "lines":{"data":[11]}
    }
  }, "result": {
    "status":"passed",
    "duration":27808
  }
},...]

Is this expected behavior? It seems to break the jenkins cucumber reporting plugin because it expects location to be a string.

ruby 2.2
cucumber 2.3.2
capybara 2.6.2

EDIT: As far as I can see, this actually happens in every one of our steps (and after hooks).

@brasmusson
Copy link
Contributor

The expected behaviour is documented in this spec. Why the json_spec-1.1.4 and capybara-2.6.2 hooks respond differently to #location I do not know.

@larryprice
Copy link

@brasmusson I've been looking into it, and it looks like the problem occurs when MultiJson.dump is called on the match location. I'm assuming this has to do with the JSON implementation being used... I'll let you know if I come up with anything else.

larryprice pushed a commit to larryprice/cucumber-ruby that referenced this issue Feb 10, 2016
@larryprice
Copy link

This commit on my fork fixes this issue for me. Although it's not quite the low-level fix I was hoping to find, all the tests still pass and I'm not sure there are any other repercussions to stringifying the object immediately. I'll likely make a PR after I've run some more verification.

@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 a pull request may close this issue.

3 participants