Open froibu opened 4 weeks ago
Hi @froibu , whenever test results are imported the first time, Xray create Test entities (i.e., Test issues) corresponding to each test method. The second time (and from there onwards) Xray will find that there are already existing Tests and reports the results (i.e., the Test Runs) to them. This is by design. In Xray, a Test is a reusable entity... an abstraction of a test idea/scenario/case/script. This behaviour:
How Xray handles test automation results, is explained for example on the handling of JUnit XML reports here.
In brief words, it processes the classname
and name
attributes on the <testcase>
elements on the XML report. It uses that as a unique identifier for the test automation code.
How that gets embed on the JUnit XML report, depends on the junit reporter for playwright (in this case).
I would advise having a look at these two free courses on the Xray Academy:
Hi @bitcoder
Thanks so much for the quick reply and clarifying my question. I would have two more question I would like you to share your thoughts upon:
Let's say we have either multiple .spec.ts test files or a single .spec.ts test file with multiple test() in it. As of now, the xml report is generated only at the very end of the playwright run e.g. if a test .spec.ts file completes before the other one, I don't have a xml report. Can we have separate reports for .spec.ts test files or for individual test() within a single .spec.ts test file?
Also, is this the proper way to attach evidence? testInfo.attach('evidence1.txt', { path: file, contentType: 'text/plain' });
Can you please share you thoughts on this? I would really appreciate it. Thanks.
You're welcome.
test('Login with invalid credentials', async({ page }, testInfo) => {
const loginPage = new LoginPage(page);
await loginPage.navigate();
await loginPage.login("demo","mode1");
const name = await loginPage.getInnerText();
//Adding Xray properties
testInfo.annotations.push({ type: 'test_key', description: 'XT-93' });
testInfo.annotations.push({ type: 'test_summary', description: 'Unsuccessful login.' });
testInfo.annotations.push({ type: 'requirements', description: 'XT-41' });
testInfo.annotations.push({ type: 'test_description', description: 'Validate that the login is unsuccessful.' });
// Capture a screenshot and attach it.
const path = testInfo.outputPath('tmp_screenshot.png');
await page.screenshot({ path });
testInfo.attachments.push({ name: 'screenshot.png', path, contentType: 'image/png' });
expect(name).toBe('Login failed. Invalid user name and/or password.');
});
Hello @bitcoder @Iv3x . I'm trying to integrate a playwright framework with JIRA Xray and stumbled upon this great project. While doing some tests, I've come across a question I cannot quite answer. Let's take for e.g. the following scenario:
Until now everything is as expected, but going forward:
Can someone please explain this behavior? It's probably working as indented but I don't see how same test if already created is being reused even though I don't explicitly map it in my playwright test via testInfo.annotations.push()