Generate Google C++ Unit Test XML Report

a 夏天 提交于 2019-11-30 08:12:46
v01d

For Linux environments:

It's simple you just have to set the GTEST_OUTPUT environment variable like this: export GTEST_OUTPUT="xml:/home/user/src". or use the -gtest_output flag set the same way.

I have referred to v01d's solution and just made a complete and properly framed answer for anyone else who might come across the same question.

Setting the Environment Variable:

  1. Goto MyComputer, right click and click on Properties.
  2. Click on the Advanced Tab, and click on Environment Variables.
  3. Click to Add a new variable and set the properties in the following way:

    • Variable: GTEST_OUTPUT

    • Value: xml:\home\user\XML_Report.xml

Restart your MSVC++ and run your program again. You should be able to find your XML Report in the corresponding folder as mentioned in the 'Value' property specified by you. Furthermore, you can even convert the xml report with the help of Microsoft Access into a particular choice of format you want. Just a simple tutorial/example of this is given here: XML Conversion.

Hope this helps!

Apart from method suggested by @The Newbie you can also generate XML report by setting flag --gtest_output="xml:\home\user\XML_Report.xml" in command line.If you are using Microsoft Visual studio, then you can add in command arguments flag --gtest_output="xml:\home\user\XML_Report.xml"

Setting the command arguments flag :

  1. Right click on project and go to properties.
  2. Go to Configuration Properties->Debugging.
  3. In Command Arguments add --gtest_output="xml:\home\user\XML_Report.xml"
Gayan Pathirage

Googletest does not generate JUnit compatible XML file, in such scenarios you need to convert the generated XML to JUnit XML format.

Reported Issue

Workaround Solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!