Jira Xray can receive a JSON object with test results. Verisoft framework builds the JSON object and fills it with the information needed in order to report the test results to Jira Xray.
In order to create the JSON object, we need to perform 2 actions:
- Use the XratPluginExtension class during the test execution
- Use the @XrayIdentifier annotation with the Jira Xray id for each test.
Let’s review the code
@ExtendWith(XrayPluginExtension.class)
public class WorkingWithXrayTests {
@Test
@XrayIdentifier("CBT-1928")
@DisplayName("Search Wikipedia test")
public void searchWikipedia() {
Report.info("This is the test");
}
}
You can see we added the extension PluginExtension.class in the first line.
Next, at the test definition part, we added the @XrayIdentifier("CBT-1928"). Note that the annotation is automatically reported to the reports via the report publisher.
Finally, after test execution, a JSON object is created and located at /target/XraryReport folder. The JSON file will look like this:
{
"tests":
[
{
"start":"2023-05-18T19:19:27+03",
"finish":"2023-05-18T19:19:27+03",
"testKey":"DEMO-124",
"status":"FAILED"
},
{
"start":"2023-05-18T19:19:27+03",
"finish":"2023-05-18T19:19:27+03",
"testKey":"DEMO-123",
"status":"PASSED"
}
],
"info":
{
"summary":"Tests Report 2023-05-18 19:19:27.19",
"description":"This report created Automatically after tests run"
}
}
Note that as of the time these lines are written, there are two types of Jira Xray servers- a cloud version and an on-prem version. There is a slight difference in the structure of the JSON between the versions. For instance - the cloud version uses PASSED and FAILED, and the on-prem version uses PASS and FAIL.