From f07896e6615a76b88e94700997f5b908c38ce1c5 Mon Sep 17 00:00:00 2001 From: Konstantin Epishev Date: Mon, 27 Jun 2022 15:27:20 +0200 Subject: [PATCH] add thread label --- packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts | 2 ++ .../allure-cucumberjs/test/specs/allure_cucumberjs_test.ts | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts b/packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts index 322ff6a29..6ac0d8c42 100644 --- a/packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts +++ b/packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts @@ -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"; @@ -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"); diff --git a/packages/allure-cucumberjs/test/specs/allure_cucumberjs_test.ts b/packages/allure-cucumberjs/test/specs/allure_cucumberjs_test.ts index a22e9a7fa..797300fa8 100644 --- a/packages/allure-cucumberjs/test/specs/allure_cucumberjs_test.ts +++ b/packages/allure-cucumberjs/test/specs/allure_cucumberjs_test.ts @@ -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"; @@ -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); @@ -302,6 +304,7 @@ 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"); @@ -309,6 +312,7 @@ describe("CucumberJSAllureReporter", () => { 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");