Unit Test Count for C++ project

Hi,

It is my first time with SonarQube and it shows me great results and there is something missing which i don’t know how to achieve.

We have some Unit Tests for C++ written in VS2019 using native Microsoft CppUnit TestFramework and using the Jenkins with a CI/CD environment.
Using vstest.console.exe, i am running my unit tests to collect code covergae and Unit test report with parameters /logger:“trx;LogFileName=UnitTestResults.trx;” /EnableCodeCoverage /collect:“Code Coverage”
Then using CodeCoverage.exe to analyze above produced coverage and generate CppCoverage.xml.

In Sonar Stage,
using TestCovergaeProperty sonar.cfamily.vscoveragexml.reportsPath i am able to generate code coverage for my C++ project.

But there is no possibility to use any TestExecution Property for .trx file generated, hence unit test field in Sonarqube is blank.

I am interested in showing the count of unit tests in Sonar for my project, how to achieve through vstest.reportsPaths.

If the suggestion is to convert it to Generic Execution Data format then please suggest me the tool to do so as i was unable to find any such tool online.

Hello @rmurarka,

Welcome to the community!

Did you try this property sonar.cfamily.cppunit.reportsPath? it represents:

Path to the directory holding the CPPUnit reports. Note that while measures such as the number of tests are displayed at project level, no drilldown is available.

Thanks,

Hi @Abbas_Sabra ,

As mentioned above i am using native Microsoft CppUnit TestFramework (Refer below image)
Using VStest, getting .trx file which is not supported by the property sonar.cfamily.cppunit.reportsPath.

To answer your question yes i tried that property and it didn’t worked for me.
If i am not wrong CppUnit - C++ port of JUnit download | SourceForge.net supported by sonar is completely different framework (not the one i am using) which generates xml reports for unit tests and can be used with the property you mentioned.

Please help me for the unit test written using framework mentioned in the below screenshot .

@rmurarka,

You are right, I meant trying to convert to the XML format and use the option.
We don’t currently support this framework directly. If you don’t find any tool that converts between them you might want to add a post in the Suggest new features category.

Thanks,