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

Missing scenario in output json when using multiple scenarios for one feature and one scenario fails #54

Open
ahelmel opened this issue Mar 13, 2023 · 0 comments

Comments

@ahelmel
Copy link

ahelmel commented Mar 13, 2023

If a feature file contains multiple scenarios, only one scenario is being exported in the resulting json output file if one scenario fails.

Using the latest cucumber-json-formatter version, version v19.0.0.
Tried the mac osx version: cucumber-json-formatter-darwin-amd64 on a mac
and the linux version on a linux machine: cucumber-json-formatter-linux-amd64

Using following very-important-feature.feature file:

#language: de
@XXX-200
Funktionalität: Very Important Feature

	@XXX-401
	Szenario: visiting the yahoo.com frontpage
		Wenn I visit yahoo.com
		Dann I should see the yahoo search bar

	@XXX-402
	Szenario: visiting the duckduckgo.com frontpage
		Wenn I visit duckduckgo.com
		Dann I should see the duckduckgo search bar

The step/test-files:

step1.steps.ts:

import { Then, When } from '@badeball/cypress-cucumber-preprocessor';

When('I visit duckduckgo.com', () => {
  cy.visit('https://www.duckduckgo.com');
});

Then('I should see the duckduckgo search bar', () => {
  cy.get('input').should('have.attr', 'placeholder', 'Search the web without being tracked');
});

step2.steps.ts:

import { Then, When } from '@badeball/cypress-cucumber-preprocessor';

When('I visit yahoo.com', () => {
  cy.visit('https://www.yahoo.com');
});

Then('I should see the yahoo search bar', () => {
  cy.get('input').should('have.attr', 'title', 'Deine Suche');
});

The cucumber-messages.ndjson file has the content:

{"testRunStarted":{"timestamp":{"seconds":1678722925,"nanos":730000000}}}
{"source":{"data":"#language: de\n@XXX-200\nFunktionalität: Very Important Feature\n\n\t@XXX-401\n\tSzenario: visiting the yahoo.com frontpage\n\t\tWenn I visit yahoo.com\n\t\tDann I should see the yahoo search bar\n\n\n\t@XXX-402\n\tSzenario: visiting the duckduckgo.com frontpage\n\t\tWenn I visit duckduckgo.com\n\t\tDann I should see the duckduckgo search bar\n","uri":"src\\features\\very-important-feature.feature","mediaType":"text/x.cucumber.gherkin+plain"}}
{"gherkinDocument":{"feature":{"tags":[{"location":{"line":2,"column":1},"name":"@XXX-200","id":"7e2e47b4-2e1a-4516-8160-fb57d5743fb7"}],"location":{"line":3,"column":1},"language":"de","keyword":"Funktionalität","name":"Very Important Feature","description":"","children":[{"scenario":{"id":"7f03cea4-1e6a-4a4a-9f18-26501d1e6632","tags":[{"location":{"line":5,"column":2},"name":"@XXX-401","id":"89c2a565-7414-468a-9bea-387fcab92b30"}],"location":{"line":6,"column":2},"keyword":"Szenario","name":"visiting the yahoo.com frontpage","description":"","steps":[{"id":"d72c98c0-1b04-4f1e-b9d7-175f9490f484","location":{"line":7,"column":3},"keyword":"Wenn ","keywordType":"Action","text":"I visit yahoo.com"},{"id":"e0a4080b-de3c-47cb-88ab-f30877dc50a4","location":{"line":8,"column":3},"keyword":"Dann ","keywordType":"Outcome","text":"I should see the yahoo search bar"}],"examples":[]}},{"scenario":{"id":"2cf1486d-8e04-4a37-8bf2-83fa335d03f0","tags":[{"location":{"line":11,"column":2},"name":"@XXX-402","id":"4a94525c-bbf2-4613-94d1-97c1a25949e0"}],"location":{"line":12,"column":2},"keyword":"Szenario","name":"visiting the duckduckgo.com frontpage","description":"","steps":[{"id":"a7c0147a-1cfc-494d-a68d-ee1fc5c9c305","location":{"line":13,"column":3},"keyword":"Wenn ","keywordType":"Action","text":"I visit duckduckgo.com"},{"id":"f0d09031-7a67-4716-a62e-cb02587c8051","location":{"line":14,"column":3},"keyword":"Dann ","keywordType":"Outcome","text":"I should see the duckduckgo search bar"}],"examples":[]}}]},"comments":[],"uri":"src\\features\\very-important-feature.feature"}}
{"pickle":{"id":"e1c36afd-3a9e-4306-910b-9b1998f2c626","uri":"src\\features\\very-important-feature.feature","astNodeIds":["7f03cea4-1e6a-4a4a-9f18-26501d1e6632"],"tags":[{"name":"@XXX-200","astNodeId":"7e2e47b4-2e1a-4516-8160-fb57d5743fb7"},{"name":"@XXX-401","astNodeId":"89c2a565-7414-468a-9bea-387fcab92b30"}],"name":"visiting the yahoo.com frontpage","language":"de","steps":[{"id":"1ea090c5-fa6f-4261-bfd1-bc2b9539d4d8","text":"I visit yahoo.com","type":"Action","astNodeIds":["d72c98c0-1b04-4f1e-b9d7-175f9490f484"]},{"id":"159c39f6-f8ad-462e-8885-1776f33096b5","text":"I should see the yahoo search bar","type":"Outcome","astNodeIds":["e0a4080b-de3c-47cb-88ab-f30877dc50a4"]}]}}
{"pickle":{"id":"ab8ada14-0ccb-4de2-983c-889dcc755c47","uri":"src\\features\\very-important-feature.feature","astNodeIds":["2cf1486d-8e04-4a37-8bf2-83fa335d03f0"],"tags":[{"name":"@XXX-200","astNodeId":"7e2e47b4-2e1a-4516-8160-fb57d5743fb7"},{"name":"@XXX-402","astNodeId":"4a94525c-bbf2-4613-94d1-97c1a25949e0"}],"name":"visiting the duckduckgo.com frontpage","language":"de","steps":[{"id":"adcf14b5-9664-4896-a7cb-e237cfb3cd70","text":"I visit duckduckgo.com","type":"Action","astNodeIds":["a7c0147a-1cfc-494d-a68d-ee1fc5c9c305"]},{"id":"8d4e2f06-68ad-4f73-8ab7-2ced650a1367","text":"I should see the duckduckgo search bar","type":"Outcome","astNodeIds":["f0d09031-7a67-4716-a62e-cb02587c8051"]}]}}
{"stepDefinition":{"id":"3ace9c3e-0891-4b6a-939c-440446ae8683","pattern":{"source":"a step","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"not available","location":{"line":0}}}}
{"stepDefinition":{"id":"a164f229-479b-4186-a911-5eb0278e1e59","pattern":{"source":"a step","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"not available","location":{"line":0}}}}
{"testCase":{"id":"9c78294f-73a2-4f35-839a-7fe95c9b8cb3","pickleId":"e1c36afd-3a9e-4306-910b-9b1998f2c626","testSteps":[{"id":"1ea090c5-fa6f-4261-bfd1-bc2b9539d4d8","pickleStepId":"1ea090c5-fa6f-4261-bfd1-bc2b9539d4d8","stepDefinitionIds":["3ace9c3e-0891-4b6a-939c-440446ae8683"]},{"id":"159c39f6-f8ad-462e-8885-1776f33096b5","pickleStepId":"159c39f6-f8ad-462e-8885-1776f33096b5","stepDefinitionIds":["a164f229-479b-4186-a911-5eb0278e1e59"]}]}}
{"stepDefinition":{"id":"b443398e-c816-4566-b303-1f1d25951fa2","pattern":{"source":"a step","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"not available","location":{"line":0}}}}
{"stepDefinition":{"id":"4a0a6811-7b4a-4993-82c7-6f7281db1bc4","pattern":{"source":"a step","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"not available","location":{"line":0}}}}
{"testCase":{"id":"915aff44-c5b2-4a35-86fe-30ab9acee3d4","pickleId":"ab8ada14-0ccb-4de2-983c-889dcc755c47","testSteps":[{"id":"adcf14b5-9664-4896-a7cb-e237cfb3cd70","pickleStepId":"adcf14b5-9664-4896-a7cb-e237cfb3cd70","stepDefinitionIds":["b443398e-c816-4566-b303-1f1d25951fa2"]},{"id":"8d4e2f06-68ad-4f73-8ab7-2ced650a1367","pickleStepId":"8d4e2f06-68ad-4f73-8ab7-2ced650a1367","stepDefinitionIds":["4a0a6811-7b4a-4993-82c7-6f7281db1bc4"]}]}}
{"testCaseStarted":{"id":"a1216698-96a7-4a57-9040-2d23bd88fdec","testCaseId":"915aff44-c5b2-4a35-86fe-30ab9acee3d4","attempt":0,"timestamp":{"seconds":1678722937,"nanos":654000000}}}
{"testStepStarted":{"testStepId":"adcf14b5-9664-4896-a7cb-e237cfb3cd70","testCaseStartedId":"a1216698-96a7-4a57-9040-2d23bd88fdec","timestamp":{"seconds":1678722937,"nanos":660000000}}}
{"testStepFinished":{"testStepId":"adcf14b5-9664-4896-a7cb-e237cfb3cd70","testCaseStartedId":"a1216698-96a7-4a57-9040-2d23bd88fdec","testStepResult":{"status":"PASSED","duration":{"seconds":1,"nanos":221000000}},"timestamp":{"seconds":1678722938,"nanos":881000000}}}
{"testStepStarted":{"testStepId":"8d4e2f06-68ad-4f73-8ab7-2ced650a1367","testCaseStartedId":"a1216698-96a7-4a57-9040-2d23bd88fdec","timestamp":{"seconds":1678722938,"nanos":881000000}}}
{"testStepFinished":{"testStepId":"8d4e2f06-68ad-4f73-8ab7-2ced650a1367","testCaseStartedId":"a1216698-96a7-4a57-9040-2d23bd88fdec","testStepResult":{"status":"PASSED","duration":{"seconds":0,"nanos":34000000}},"timestamp":{"seconds":1678722938,"nanos":915000000}}}
{"testCaseFinished":{"testCaseStartedId":"a1216698-96a7-4a57-9040-2d23bd88fdec","timestamp":{"seconds":1678722938,"nanos":923000000},"willBeRetried":false}}
{"testRunFinished":{"timestamp":{"seconds":1678722941,"nanos":453000000}}}

After running the "cat cucumber-messages.ndjson | cucumber-json-formatter > cucumber-report.json" command the output json cucumber-report.json contains the content:

[
  {
    "description": "",
    "elements": [
      {
        "description": "",
        "id": "very-important-feature;visiting-the-duckduckgo.com-frontpage",
        "keyword": "Szenario",
        "line": 12,
        "name": "visiting the duckduckgo.com frontpage",
        "steps": [
          {
            "keyword": "Wenn ",
            "line": 13,
            "name": "I visit duckduckgo.com",
            "result": {
              "duration": 1268000000,
              "status": "passed"
            },
            "match": {
              "location": "not available:0"
            }
          },
          {
            "keyword": "Dann ",
            "line": 14,
            "name": "I should see the duckduckgo search bar",
            "result": {
              "duration": 33000000,
              "status": "passed"
            },
            "match": {
              "location": "not available:0"
            }
          }
        ],
        "type": "scenario",
        "tags": [
          {
            "line": 2,
            "name": "@XXX-200"
          },
          {
            "line": 11,
            "name": "@XXX-402"
          }
        ]
      }
    ],
    "id": "very-important-feature",
    "keyword": "Funktionalität",
    "line": 3,
    "name": "Very Important Feature",
    "uri": "src\\features\\2_B2B-278.feature",
    "tags": [
      {
        "line": 2,
        "name": "@XXX-200"
      }
    ]
  }
]

The data for the "yahoo" scenario is missing in the output json file.
It contains only succeeded scenario. The failed scenario is missing.

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

No branches or pull requests

1 participant