In this tutorial, we will create some tests in C++ using the Google Test framework, which supports out-of-the-box JUnit reports.
- Google Test
This example is based on the code from https://github.com/snikulov/google-test-examples, although native samples provided by Google test frameworks could also be used (as of Google test release 1.8.0).
Below are three tests that validate the array sorting function.
In order to run the tests, we need to compile the code first.
After running the tests and generating the JUnit XML reports (e.g., test_detail.xml), it can be imported to Xray (either by the REST API or through the Import Execution Results action within the Test Execution).
JUnit's Test Case is mapped to a Generic Test in Jira, and the Generic Test Definition field contains the "name of the test case" concatenated with the "name of the test within the test case".
About Google Test's nomenclature
As stated by Google Test,
TEST() arguments go from general to specific. The first argument is the name of the test case, and the second argument is the test's name within the test case. Both names must be valid C++ identifiers, and they should not contain underscore (
_). A test's full name consists of its containing test case and its individual name. Tests from different test cases can have the same individual name.
The Execution Details of the Generic Test contains information about the Test Suite, which in this case corresponds to Google Test's "test case name".