forked from Klaveness-Digital/cypress-cucumber-preprocessor
-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add preliminary version of message merging
- Loading branch information
Showing
15 changed files
with
448 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[← Back to documentation](readme.md) | ||
|
||
# Parallelization using Cypress Cloud & merging reports | ||
|
||
[Parallelization](https://docs.cypress.io/guides/cloud/smart-orchestration/parallelization) using Cypress Cloud is where you run `cypress run --record --parallel` on N machine in order to improve execution time. This typically generates N reports. These are obviously related to each other. They are unique sets of spec results, with no overlap, obtained through sharding (weighing and distribution by Cypress Cloud). | ||
|
||
Different messages reports can be combined into a single messages report using the following executable. This behaves like `cat`, it reads file arguments and outputs a combined report to stdout. | ||
|
||
``` | ||
$ npx cucumber-merge-messages *.ndsjon | ||
``` | ||
|
||
Alternatively you can redirect the output to a new file. | ||
|
||
``` | ||
$ npx cucumber-merge-messages *.ndsjon > combined-cucumber-messages.ndjson | ||
``` | ||
|
||
Only *messages reports* can be merged. JSON and HTML reports are both products of messages and if you require either, then you can use the [JSON formatter](json-formatter.md) or [HTML formatter](html-formatter.md) to create one from the other, like shown below. | ||
|
||
``` | ||
$ npx cucumber-merge-messages *.ndsjon > combined-cucumber-messages.ndjson | ||
$ npx cucumber-json-formatter < combined-cucumber-messages.ndjson > cucumber-report.json | ||
$ npx cucumber-html-formatter < combined-cucumber-messages.ndjson > cucumber-report.html | ||
``` | ||
|
||
## How do I collect reports created on N different machines? | ||
|
||
You need to consult your CI provider's documentation. Below is a very simple example illustrating the use of *artifacts* on Gitlab CI/CD to solve this. The reason for specifying `messagesOutput` is because on Gitlab, [artifacts with the same name from different jobs overwrite each other](https://gitlab.com/gitlab-org/gitlab/-/issues/244714). | ||
|
||
```yaml | ||
stages: | ||
- test | ||
- report | ||
|
||
cypress: | ||
stage: test | ||
parallel: 5 | ||
script: | ||
- npx cypress run --record --parallel --env messagesOutput=cucumber-messages-$CI_NODE_INDEX.ndjson | ||
artifacts: | ||
paths: | ||
- *.ndjson | ||
|
||
combine: | ||
stage: report | ||
script: | ||
- npx cucumber-merge-messages *.ndsjon > cucumber-messages.ndjson | ||
- npx cucumber-json-formatter < cucumber-messages.ndjson > cucumber-report.json | ||
- npx cucumber-html-formatter < cucumber-messages.ndjson > cucumber-report.html | ||
artifacts: | ||
paths: | ||
- cucumber-messages.ndjson | ||
- cucumber-report.json | ||
- cucumber-report.html | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{"meta":"meta"} | ||
{"testRunStarted":{"timestamp":{"seconds":0,"nanos":0}}} | ||
{"source":{"data":"Feature: another feature\n Scenario: another scenario\n Given a step","uri":"cypress/e2e/b.feature","mediaType":"text/x.cucumber.gherkin+plain"}} | ||
{"gherkinDocument":{"feature":{"tags":[],"location":{"line":1,"column":1},"language":"en","keyword":"Feature","name":"another feature","description":"","children":[{"scenario":{"id":"id","tags":[],"location":{"line":2,"column":3},"keyword":"Scenario","name":"another scenario","description":"","steps":[{"id":"id","location":{"line":3,"column":5},"keyword":"Given ","keywordType":"Context","text":"a step"}],"examples":[]}}]},"comments":[],"uri":"cypress/e2e/b.feature"}} | ||
{"pickle":{"id":"id","uri":"cypress/e2e/b.feature","astNodeIds":["id"],"tags":[],"name":"another scenario","language":"en","steps":[{"id":"id","text":"a step","type":"Context","astNodeIds":["id"]}]}} | ||
{"stepDefinition":{"id":"id","pattern":{"type":"CUCUMBER_EXPRESSION","source":"a step"},"sourceReference":{"uri":"not available","location":{"line":0}}}} | ||
{"testCase":{"id":"id","pickleId":"id","testSteps":[{"id":"id","pickleStepId":"id","stepDefinitionIds":["id"]}]}} | ||
{"testCaseStarted":{"id":"id","testCaseId":"id","attempt":0,"timestamp":{"seconds":0,"nanos":0}}} | ||
{"testStepStarted":{"testStepId":"id","testCaseStartedId":"id","timestamp":{"seconds":0,"nanos":0}}} | ||
{"testStepFinished":{"testStepId":"id","testCaseStartedId":"id","testStepResult":{"status":"PASSED","duration":0},"timestamp":{"seconds":0,"nanos":0}}} | ||
{"testCaseFinished":{"testCaseStartedId":"id","timestamp":{"seconds":0,"nanos":0},"willBeRetried":false}} | ||
{"testRunFinished":{"timestamp":{"seconds":0,"nanos":0}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Feature: merging reports | ||
|
||
Scenario: two features | ||
Given additional preprocessor configuration | ||
""" | ||
{ | ||
"messages": { | ||
"enabled": true | ||
} | ||
} | ||
""" | ||
And a file named "cypress/e2e/a.feature" with: | ||
""" | ||
Feature: a feature | ||
Scenario: a scenario | ||
Given a step | ||
""" | ||
And a file named "cypress/e2e/b.feature" with: | ||
""" | ||
Feature: another feature | ||
Scenario: another scenario | ||
Given a step | ||
""" | ||
And a file named "cypress/support/step_definitions/steps.js" with: | ||
""" | ||
const { Given } = require("@badeball/cypress-cucumber-preprocessor"); | ||
Given("a step", function() {}) | ||
""" | ||
When I run cypress with "--spec cypress/e2e/a.feature --env messagesOutput=cucumber-messages-a.ndjson" (expecting exit code 0) | ||
And I run cypress with "--spec cypress/e2e/b.feature --env messagesOutput=cucumber-messages-b.ndjson" (expecting exit code 0) | ||
And I merge the messages reports | ||
Then there should be a messages similar to "fixtures/multiple-features.ndjson" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.