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

Add ability to link test results with issues and tms. #224

Merged
merged 3 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions packages/allure-cucumberjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,33 @@ export default class Reporter extends CucumberJSAllureFormatter {
constructor(options) {
super(
options,
new AllureRuntime({ resultsDir: "./out/allure-results" }),
new AllureRuntime({ resultsDir: "./allure-results" }),
{
labels: {
issue: [/@bug_(.*)/],
epic: [/@feature:(.*)/]
}
epic: [/@feature:(.*)/],
issue: [/@issue:(.*)/],
tms: [/@tms:(.*)/],
},
issuesTrackerUrlPattern: "http://localhost:8080/issue/%s",
damonpam marked this conversation as resolved.
Show resolved Hide resolved
testsManagementUrlPattern: "http://localhost:8080/tms/%s"
}
);
}
}
```
This class MUST:
* Be a default export
* Extend `CucumberJSAllureFormatter`
* Take 1 argument in constructor and pass it to `super()` as first argument
* Second `super()` argument is `AllureRuntime` instance
* Third is a config, currently allows to map tags to Allure labels
This class **MUST**:
* Be a default export.
* Extend `CucumberJSAllureFormatter`.
* First `super()` argument is the first argument in the `constructor`.
* Second `super()` argument is an `AllureRuntime` instance.
* Third argument is a config object which allows:
* Map tags to Allure labels.
* Add links to external sites like JIRA, XRAY, etc. `%s` will be auto-replaced by the issue id. Example:
```gherkin
@issue=TEST-1
Scenario: Example for scenario issue link check
Then the issue link should be "http://localhost:8080/issue/TEST-1"
```

Then pass with reporter as a Cucumber formatter:
```
Expand Down Expand Up @@ -68,3 +78,5 @@ Ilya Korobitsyn <[email protected]>
#### Contributors

* Claudia Hardman <[email protected]>
* Max Di Maria <[email protected]>
* Daniel Montesinos <[email protected]>
46 changes: 46 additions & 0 deletions packages/allure-cucumberjs/features/links.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Feature: Links

Background:
Given a allure formatter file with config:
"""
{
labels: {
issue: [/@issue=(.*)/],
tms: [/@tms=(.*)/]
},
issuesTrackerUrlPattern: "http://localhost:8080/issue/%s",
testsManagementUrlPattern: "http://localhost:8080/tms/%s"
}
"""

Scenario: Reporting scenario issue link
Given a feature:
"""
Feature: Feature issue links
@issue=TEST
Scenario: Example for scenario issue link check
When do passing step
Then do passing step
"""
When I run cucumber-js with allure
Then it passes
Then it has result for "Example for scenario issue link check"

When I choose result for "Example for scenario issue link check"
Then it has link with url "http://localhost:8080/issue/TEST" with name "TEST" and with type "issue"

Scenario: Reporting scenario tms link
Given a feature:
"""
Feature: Feature issue links
@tms=TEST
Scenario: Example for scenario tms link check
When do passing step
Then do passing step
"""
When I run cucumber-js with allure
Then it passes
Then it has result for "Example for scenario tms link check"

When I choose result for "Example for scenario tms link check"
Then it has link with url "http://localhost:8080/tms/TEST" with name "TEST" and with type "tms"
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { StepResult, TestResult } from "allure-js-commons";
import chai, { expect } from "chai";
import { Then, When } from "cucumber";
import { expect } from "chai";
import chai from "chai";
import { TestResult } from "allure-js-commons";
import { ChaiPartial } from "../support/chai-partial";
import { StepResult } from "allure-js-commons";

chai.use(ChaiPartial);

Expand Down Expand Up @@ -35,3 +33,8 @@ Then(/^it has label "(.*)" with value "(.*)"$/, function(name: string, value: st
Then(/^it has description "(.*)"$/, function(description: string) {
expect(this.ctx).partial({ description });
});

Then(/^it has link with url "(.*)" with name "(.*)" and with type "(.*)"$/,
function(url: string, name: string, type: string) {
expect(this.ctx).partial({ links: [{ url, name, type }] });
});
8 changes: 8 additions & 0 deletions packages/allure-cucumberjs/src/CucumberAllureInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ export class CucumberAllureInterface extends Allure {
addLabel(name: string, value: string): void {
this.currentTest.addLabel(name, value);
}

addIssue(url: string, name: string) {
this.currentTest.addIssue(url, name);
}

addTMS(url: string, name: string) {
this.currentTest.addTMS(url, name);
}
}

export class WrappedStep {
Expand Down
Loading