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

Embedding with scenario outlines, JSON formatter and --expand puts all embeds into the first scenario #806

Closed
jfinkhaeuser opened this issue Feb 13, 2015 · 3 comments

Comments

@jfinkhaeuser
Copy link

Software

cucumber: 2.0.0.rc.3
gherkin: 2.12.2

Expected Behaviour

Each scenario expanded from an example line contains its own embed.

Actual Behaviour

The first scenario contains embeds from all scenarios.

Example

Based on the example as in related issue #804; the only change is to add another example to the feature file:

Feature: JSON embedding
  Scenario Outline: can't embed in the first step with JSON formatter
    Given I try to embed <something>

    Examples:
      | something |
      | foo       |
      | bar       |
[
  {
    "keyword": "Feature",
    "name": "JSON embedding",
    "line": 1,
    "description": "",
    "id": "json-embedding",
    "uri": "features/json_embed.feature",
    "elements": [
      {
        "keyword": "Scenario Outline",
        "name": "can't embed in the first step with JSON formatter",
        "line": 8,
        "description": "",
        "id": "json-embedding;can't-embed-in-the-first-step-with-json-formatter;;2",
        "type": "scenario",
        "steps": [
          {
            "keyword": "Given ",
            "name": "I try to embed foo",
            "line": 8,
            "embeddings": [
              {
                "mime_type": "application/octet-stream",
                "data": "Zm9v"
              },
              {
                "mime_type": "application/octet-stream",
                "data": "YmFy"
              }
            ],
            "match": {
              "arguments": [
                {
                  "offset": 15,
                  "val": "foo"
                }
              ],
              "location": "features/step_definitions/steps.rb:1"
            },
            "result": {
              "status": "passed",
              "duration": 63228
            }
          }
        ]
      },
      {
        "keyword": "Scenario Outline",
        "name": "can't embed in the first step with JSON formatter",
        "line": 9,
        "description": "",
        "id": "json-embedding;can't-embed-in-the-first-step-with-json-formatter;;3",
        "type": "scenario",
        "steps": [
          {
            "keyword": "Given ",
            "name": "I try to embed bar",
            "line": 9,
            "match": {
              "arguments": [
                {
                  "offset": 15,
                  "val": "bar"
                }
              ],
              "location": "features/step_definitions/steps.rb:1"
            },
            "result": {
              "status": "passed",
              "duration": 31634
            }
          }
        ]
      }
    ]
  }
]

Note the following test values and their corresponding base64 encoded value:

text base64
foo Zm9v
bar YmFy
@brasmusson
Copy link
Contributor

To be precise, in case of scenario outlines in expanded mode, the embeddings are recorded in the preceding step, unless it is the very first step executed, then the embeddings are recorded correctly in that step. On JRuby, on the other hand, a NullPointerException is thrown from the (Java version of) the gherkin library when using embed in the first step executed for an scenario outline (in expanded mode).

@mattwynne
Copy link
Member

Yeah, this is bit of a mess.

@brasmusson how hard would it be to fix this? Is the fix likely to be in Gherkin or Cucumber?

@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