Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Xray - Playwright - how to add more different testInfo annotations

Shiv Jirwankar August 16, 2024

Scenario

I am linking Playwright tests with Xray props so that I can use Xray rest apis to send the executed automated test results to Xray. 

 

Problem

I want to add some more test info like browser name, execution environment, etc to test case. 

At present, I am adding testInfo annotation like this to Playwright test:

test('some test', async () => {

 testInfo.annotations.push({ type: 'test_key', description: testKeyValue });


// my test body

});

I am not sure what are the string to define in `type` key here so that I can display testInfo like browser, environment, etc. 

 

Also, is there any other better way to map testInfo prop for each test in Playwright? Like we are doing it for every test, would be better if that can be done once for all the tests. 

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Francisco Fonseca _Xray_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 20, 2024

Hi @Shiv Jirwankar ,

I hope you're doing well!

Xray can process test automation results using different test report formats.

One of the supported formats is JUnit XML; in this case, Xray can process it accordingly with the rules found in this documentation:

https://docs.getxray.app/display/XRAY/Taking+advantage+of+JUnit+XML+reports 

Xray supports an enhanced JUnit XML that can process additional test-level properties, such as test_key. To be able to generate to process some user-defined annotations, and generate this enhanced JUnit XML report, you need to use a custom reporter for JUnit:

https://github.com/Xray-App/playwright-junit-reporter 

Note that you cannot add random annotations.

Xray only processes a few specific ones, as described on the first link shared earlier.

To achieve your goal, you would probably need to provide that info either as a test run comment using the testrun_comment type, or use specific test run custom fields (you would need to create them  before on Xray side) to embed that information; on the latter case, you would need to use a type such as "testrun_customfield:your_specific_field"

Hope it helps, best, Francisco

TAGS
AUG Leaders

Atlassian Community Events