Get XML reports in TeamCity from Google Test

I am trying to figure out how to perform unit tests using Google Test and send TeamCity results.

I ran my tests and printed the results in xml using the command line argument --gtest_output="xml:test_results.xml" .

I am trying to read this xml in TeamCity. I don’t see how I can get the XML reports passed to TeamCity during build / run ...

Except XML Report Processing :

I added the XML processing of reports, added Google Test, then ... it asks me to specify the monitoring rules, and I added the path to the XML file ... I don’t understand what monitoring rules or how to create them ...

[However, I do not see anywhere in the generated xml that he intends to talk with TeamCity ...]

The journal has:

 Google Test report watcher [13:06:03][Google Test report watcher] No reports found for paths: [13:06:03][Google Test report watcher] C:\path\test_results.xml [13:06:03]Publishing internal artifacts 

And, of course, no report results.

Can someone direct me properly to import the xml test result file into TeamCity? Thank you very much!

Edit: Is it possible that processing XML reports only processes reports created during assembly? (which Google Test doesn’t?) and ignores previously generated reports as "obsolete", simply saying that it cannot find them - or is in the wrong format, or ... however, should I read the message above?

+4
source share
2 answers

I found an error report that shows that xml reports that are not generated during assembly are ignored, which makes newcomers like me believe that they may not be generated correctly.

Two simple solutions:

1) Create a post build script

2) Add a build step that invokes a command line executable with a command line argument. Example:

Add Build Step

enter image description here

Add Build Function - XML ​​Report Processing

enter image description here

+8
source

I had similar problems to make it work. This is how I started to work.

When you invoke your google test executable from the command line, add% teamcity.build.checkoutDir% to the name of your xml file to set its path as follows:

 --gtest_output=xml:%teamcity.build.checkoutDir%test_results.xml 

Then, when you configure additional build functions on the build steps page, add this line to your monitoring rules:

 %teamcity.build.checkoutDir%test_results.xml 

Now the paths match and are in the assembly directory.

+1
source

Source: https://habr.com/ru/post/1440136/


All Articles