Skip to content

JsonFormatter attach text to last step when sceneario.write is invoked from after hook #1080

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

Closed
fmarmar opened this issue Nov 10, 2016 · 3 comments

Comments

@fmarmar
Copy link

fmarmar commented Nov 10, 2016

Summary

If an after hook invoke the method scenario.write(), the text is written as an entry in the node 'output' of the last step instead of the hook step in 'after' node

Expected Behavior

Given the following code:

@After
public void endScenario(Scenario scenario) {
   scenario.write("test")
}

The cucumber json report should be:

[
  {
    "line": 1,
    "elements": [
      {
        "before": [
          {
            "result": {
              "duration": 102032546,
              "status": "passed"
            },
            "match": {
              "location": "Hooks.startScenario(Scenario)"
            }
          }
        ],
        "line": 20,
        "name": "Example",
        "description": "",
        "id": "example;example",
        "after": [
          {
            "output": [
              "test"
            ],
            "result": {
              "duration": 1519175111,
              "status": "passed"
            },
            "match": {
              "location": "Hooks.endScenario(Scenario)"
            }
          }
        ],
        "type": "scenario",
        "keyword": "Scenario",
        "steps": [
          {
            "result": {
              "duration": 1282972237,
              "status": "passed"
            },
            "line": 39,
            "name": "Example test",
            "match": {
              "location": "Step.example"
            },
            "keyword": "Given"
          }
        ]
      }
    ]
  }
]

Current Behavior

[
  {
    "line": 1,
    "elements": [
      {
        "before": [
          {
            "result": {
              "duration": 102032546,
              "status": "passed"
            },
            "match": {
              "location": "Hooks.startScenario(Scenario)"
            }
          }
        ],
        "line": 20,
        "name": "Example",
        "description": "",
        "id": "example;example",
        "after": [
          {
            "result": {
              "duration": 1519175111,
              "status": "passed"
            },
            "match": {
              "location": "Hooks.endScenario(Scenario)"
            }
          }
        ],
        "type": "scenario",
        "keyword": "Scenario",
        "steps": [
          {
            "output": [
              "test"
            ],
            "result": {
              "duration": 1282972237,
              "status": "passed"
            },
            "line": 39,
            "name": "Example test",
            "match": {
              "location": "Step.example"
            },
            "keyword": "Given"
          }
        ]
      }
    ]
  }
]

Context & Motivation

Using an external tool to create an html report, I expect the text to be associated to the hook, not the las step

Your Environment

  • Version used: 1.2.4
@brasmusson
Copy link
Contributor

Since this bug is in Gherkin v2.12.2, this issue will be fixed when Cucumber-JVM is updated to use Gherkin v4 (#1035).

@brasmusson
Copy link
Contributor

Now when #1035 has been merged, the 2.0.0-SNAPSHOT version from the master branch (with the groupId io.cucumber), the Json Formatter handles writes from the after 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

3 participants