Skip to content

Commit

Permalink
Enhancement on scenario name (closes #37 #40)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmsterGet committed Aug 28, 2020
1 parent 1c4d62a commit 124fa3e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
42 changes: 19 additions & 23 deletions modules/cucumber-reportportal-formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,31 +162,27 @@ const createRPFormatterClass = (config) => {
[utils.getUri(event.sourceLocation.uri), event.sourceLocation.line].join(':');
const { featureId } = this.documentsStorage.featureData[event.sourceLocation.uri];

if (this.contextState.context.lastScenarioDescription !== name) {
this.contextState.context.lastScenarioDescription = name;
this.contextState.context.outlineRow = 0;
} else if (event.attemptNumber < 2) {
this.contextState.context.outlineRow += 1;
name += ` [${this.contextState.context.outlineRow}]`;
if (!(name in this.contextState.context.scenarioNames)) {
this.contextState.context.scenarioNames[name] = 1;
} else {
this.contextState.context.scenarioNames[name] += 1;
name += ` [${this.contextState.context.scenarioNames[name]}]`;
}

// BeforeScenario
if (this.isScenarioBasedStatistics || event.attemptNumber < 2) {
this.contextState.context.scenarioId = this.reportportal.startTestItem(
{
name,
startTime: this.reportportal.helpers.now(),
type: this.isScenarioBasedStatistics ? 'STEP' : 'TEST',
description,
codeRef: utils.formatCodeRef(event.sourceLocation.uri, name),
parameters: this.contextState.context.scenario.parameters,
attributes: itemAttributes,
retry: false,
},
this.contextState.context.launchId,
featureId,
).tempId;
}
this.contextState.context.scenarioId = this.reportportal.startTestItem(
{
name,
startTime: this.reportportal.helpers.now(),
type: this.isScenarioBasedStatistics ? 'STEP' : 'TEST',
description,
codeRef: utils.formatCodeRef(event.sourceLocation.uri, name),
parameters: this.contextState.context.scenario.parameters,
attributes: itemAttributes,
retry: false,
},
this.contextState.context.launchId,
featureId,
).tempId;
}

onTestStepStarted(event) {
Expand Down
1 change: 1 addition & 0 deletions modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const cleanContext = () => ({
background: null,
failedScenarios: {},
scenariosCount: {},
scenarioNames: {},
lastScenarioDescription: null,
scenario: null,
step: null,
Expand Down
1 change: 1 addition & 0 deletions tests/cucumber-reportportal-formatter.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* These tests need to be rewritten to reflect the refactoring of the agent. Plans for version 5.0.1. */
const { createRPFormatterClass } = require('../modules');
const {
ContextMock,
Expand Down

0 comments on commit 124fa3e

Please sign in to comment.