Skip to content

Commit

Permalink
add thread label
Browse files Browse the repository at this point in the history
  • Loading branch information
epszaw committed Jun 27, 2022
1 parent 7082415 commit f07896e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os from "os";
import process from "process";
import { World as CucumberWorld, Formatter } from "@cucumber/cucumber";
import { IFormatterOptions } from "@cucumber/cucumber/lib/formatter";
import TestCaseHookDefinition from "@cucumber/cucumber/lib/models/test_case_hook_definition";
Expand Down Expand Up @@ -176,6 +177,7 @@ export class CucumberJSAllureFormatter extends Formatter {
this.currentTest.name = pickle.name;

this.currentTest?.addLabel(LabelName.HOST, os.hostname());
this.currentTest?.addLabel(LabelName.THREAD, process.getuid().toString());
this.currentTest?.addLabel(LabelName.LANGUAGE, "javascript");
this.currentTest?.addLabel(LabelName.FRAMEWORK, "cucumberjs");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import sinon from "sinon";
import os from "os";
import process from "process";
import { LabelName, Status } from "allure-js-commons";
import { expect } from "chai";
import sinon from "sinon";
import { ITestFormatterOptions, runFeatures } from "../helpers/formatter_helpers";
import { buildSupportCodeLibrary } from "../helpers/runtime_helpers";

Expand Down Expand Up @@ -293,6 +294,7 @@ describe("CucumberJSAllureReporter", () => {

it("should create labels", async () => {
sinon.stub(os, "hostname").returns("127.0.0.1");
sinon.stub(process, "getuid").returns(123);

const results = await runFeatures(dataSet.withTags);
expect(results.tests).length(1);
Expand All @@ -302,13 +304,15 @@ describe("CucumberJSAllureReporter", () => {
const feature = results.tests[0].labels.find((label) => label.name === LabelName.FEATURE);
const suite = results.tests[0].labels.find((label) => label.name === LabelName.SUITE);
const host = results.tests[0].labels.find((label) => label.name === LabelName.HOST);
const thread = results.tests[0].labels.find((label) => label.name === LabelName.THREAD);
const tags = results.tests[0].labels.filter((label) => label.name === LabelName.TAG);

expect(language?.value).eq("javascript");
expect(framework?.value).eq("cucumberjs");
expect(feature?.value).eq("a");
expect(suite?.value).eq("b");
expect(host?.value).eq("127.0.0.1");
expect(thread?.value).eq("123");
expect(tags).length(2);
expect(tags[0].value).eq("@foo");
expect(tags[1].value).eq("@bar");
Expand Down

0 comments on commit f07896e

Please sign in to comment.