Skip to content

Commit

Permalink
EPMRPP-80545 || release preparation (#114)
Browse files Browse the repository at this point in the history
* EPMRPP-80545 || release preparation

* EPMRPP-80545 || code review fixes - 1

* EPMRPP-80545 || move retry flag to testCase storage

* EPMRPP-80545 || code review fixes - 2

Co-authored-by: Mikhail Sidarkevich <[email protected]>
  • Loading branch information
chivekrodis and Mikhail Sidarkevich authored Nov 28, 2022
1 parent 784e3ca commit 1999eea
Show file tree
Hide file tree
Showing 6 changed files with 337 additions and 34 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
### Added
- Added support for 7-8 versions of `@cucumber/cucumber` package

### Changed
- Package size reduced

### Updated
- `@reportportal/client-javascript` version to the latest

## [5.0.2] - 2021-06-23
### Fixed
- Launch status calculation
Expand Down
28 changes: 4 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Agent for integration CucumberJS with ReportPortal.
* More about [CucumberJS](https://cucumber.io/docs/installation/javascript/)
* More about [ReportPortal](http://reportportal.io/)

This agent works well with cucumber versions from 4.x to 6.x inclusive.
This agent works well with cucumber versions from 7.x.
Documentation for legacy cucumber versions from 4.x to 6.x can be found [here](/modules/api/deprecated/README.md)

## Install agent to your project dir

Expand Down Expand Up @@ -53,7 +54,6 @@ npm install --save-dev @reportportal/agent-js-cucumber
"endpoint": "${rp.endpoint}/api/v1",
"launch": "${rp.launch}",
"project": "${rp.your_project}",
"takeScreenshot": "onFailure",
"description": "Awesome launch description.",
"attributes": [
{
Expand All @@ -69,9 +69,8 @@ npm install --save-dev @reportportal/agent-js-cucumber
}
```
`takeScreenshot` - if this option is defined then framework will take screenshot with _protractor or webdriver_ API if step has failed<br/>
`mode` - Launch mode. Allowable values *DEFAULT* (by default) or *DEBUG*.<br/>
`debug` - this flag allows seeing the logs of the `client-javascript`. Useful for debugging.
`debug` - this flag allows seeing the logs of the `client-javascript`. Useful for debugging.<br/>
`restClientConfig` (optional) - The object with `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, may contain other client options eg. `timeout`.
3. Create Report Portal formatter in a new js file, for example `reportPortalFormatter.js`:
Expand All @@ -86,7 +85,7 @@ npm install --save-dev @reportportal/agent-js-cucumber
4. Import RPWorld (provides API for logging and data attaching) into /features/step_definitions/support/world.js
```javascript
let { setWorldConstructor } = require('cucumber');
let { setWorldConstructor } = require('@cucumber/cucumber');
let { RPWorld } = require('@reportportal/agent-js-cucumber');
setWorldConstructor(RPWorld);
```
Expand Down Expand Up @@ -120,8 +119,6 @@ npm install --save-dev @reportportal/agent-js-cucumber
More info in the [examples](https://github.com/reportportal/examples-js/tree/master/example-cucumber) repository.
### TODO parallel launch
## Rerun
To report [rerun](https://github.com/reportportal/documentation/blob/master/src/md/src/DevGuides/rerun.md) to the report portal you need to specify the following options to the config file:
Expand Down Expand Up @@ -160,23 +157,6 @@ To report your steps as logs, you need to pass an additional parameter to the ag

This will report your your steps with logs to a log level without creating statistics for every step.

## Reporting skipped cucumber steps as failed

By default, cucumber marks steps which follow a failed step as `skipped`.
When `scenarioBasedStatistics` is set to `false` (the default behavior)
Report Portal reports these steps as failures to investigate.

To change this behavior and instead mark skipped steps which follow a failed step as `cancelled`,
you need to add an additional parameter to the agent config: `"reportSkippedCucumberStepsOnFailedTest": false`

```json
{
"reportSkippedCucumberStepsOnFailedTest": false
}
```

Steps which are marked as `skipped` that do not follow a failed step will continue to mark the step and the scenario as `skipped`.

## API

### Attachments
Expand Down
16 changes: 8 additions & 8 deletions modules/api/current.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ module.exports = {
this.storage = new Storage();
this.customLaunchStatus = null;
this.codeRefIndexesMap = new Map();
this.isRetry = false;

this.options.eventBroadcaster.on('envelope', (event) => {
const [key] = Object.keys(event);
Expand Down Expand Up @@ -121,7 +120,7 @@ module.exports = {
onTestCaseStartedEvent(data) {
const { id, testCaseId, attempt } = data;
this.storage.setTestCaseStartedId(id, testCaseId);
const { pickleId } = this.storage.getTestCase(testCaseId);
const { pickleId, isRetry: isTestCaseRetried } = this.storage.getTestCase(testCaseId);
const {
uri: pickleFeatureUri,
astNodeIds: [scenarioId, parametersId],
Expand Down Expand Up @@ -186,8 +185,10 @@ module.exports = {
scenario = currentNode.scenario;
}

let isRetry = isTestCaseRetried;
if (attempt > 0) {
this.isRetry = true;
isRetry = true;
this.storage.updateTestCase(testCaseId, { isRetry });

if (!this.isScenarioBasedStatistics) return;
}
Expand All @@ -200,11 +201,11 @@ module.exports = {
const scenarioCodeRefIndexValue = this.codeRefIndexesMap.get(currentNodeCodeRef);
this.codeRefIndexesMap.set(currentNodeCodeRef, (scenarioCodeRefIndexValue || 0) + 1);
const name =
scenarioCodeRefIndexValue && !this.isRetry
scenarioCodeRefIndexValue && !isRetry
? `${scenarioName} [${scenarioCodeRefIndexValue}]`
: scenarioName;
const scenarioCodeRef =
scenarioCodeRefIndexValue && !this.isRetry
scenarioCodeRefIndexValue && !isRetry
? `${currentNodeCodeRef} [${scenarioCodeRefIndexValue}]`
: currentNodeCodeRef;
const testData = {
Expand Down Expand Up @@ -244,7 +245,7 @@ module.exports = {
const stepCodeRefIndexValue = this.codeRefIndexesMap.get(codeRef);
this.codeRefIndexesMap.set(codeRef, (stepCodeRefIndexValue || 0) + 1);
const name =
stepCodeRefIndexValue && !this.isRetry
stepCodeRefIndexValue && !testCase.isRetry
? `${stepName} [${stepCodeRefIndexValue}]`
: stepName;

Expand All @@ -254,7 +255,7 @@ module.exports = {
type,
codeRef,
hasStats: !this.isScenarioBasedStatistics,
retry: !this.isScenarioBasedStatistics && this.isRetry,
retry: !this.isScenarioBasedStatistics && !!testCase.isRetry,
};

if (!this.isScenarioBasedStatistics && step.astNodeIds && step.astNodeIds.length > 1) {
Expand Down Expand Up @@ -470,7 +471,6 @@ module.exports = {
this.storage.removeSteps(testCaseId);
this.storage.removeTestCase(testCaseId);
this.storage.setScenarioTempId(null);
this.isRetry = false;
}
},
onTestRunFinishedEvent() {
Expand Down
Loading

0 comments on commit 1999eea

Please sign in to comment.