SeleniumJavaScript-如何在Jest测试用例中设置测试id



我想在Jest中为每个测试设置一个id,这样我就可以唯一地识别它们。

它类似于TestNG中的@TestParamters/@Parameters

此处-https://www.gurock.com/testrail/docs/api/reference/results#addresult。如果你看看这里给出的终点,它要求:test_id

因此,我还想为我的每个测试用例提供一个id,并在TestRail中获取该id。

检查@jest-reporters/testrail插件。它是Jest的TestRail模块。帮助在TestRail上为多个套件创建测试运行并发送结果。

首先,安装插件

npm i @jest-reporters/testrail

第二,更新jest.config.js

module.exports = {
...
reporters: [
["testrail", {
project_id: "1"
}]
]
};

第三,在你的测试用例文件

// "1:" this is Suite ID from Test Rail (Will work only for top)
describe("TestRail[1] Suite", () => {
// "11:" this is Case ID from Test Rail
it("TestRail[11] Test success", async() => {
expect(1).toBe(1);
});
it("TestRail[12] Test fail", async() => {
expect(1).toBe(0);
});
xit("TestRail[13] Test skip", async() => {
expect(1).toBe(1);
});
});

TestRail中的Suite ID必须添加到顶部描述((的开头,ID应在TestRail[ID]中。

TestRail中的Case ID必须添加到每个it((描述的开头,ID应该在TestRail[ID]中。

最新更新