Reputation: 875
I am using TFS 2015 (update 2), C++, Google test and Sonarqube 5.6 (with Cxx community plugin). I am able to import the coverage, compute duplication, create issues using cppcheck but the number of tests is not importing in sonarqube.
I need to generate a Junit-like XML file using <test executable> --gtest_output=xml:<filename>
but in TFS (vNext), I use the VSTestTask which uses vstest.console.exe to run my *Test.exe and there seems to be no way to output as xml (it defaults to .trx).
Has anyone managed to correctly import GTest test metrics into sonarqube? Is a XSLT to transform from trx to xunit the only way...?
May be i need to properly fill in the sonar.cxx.vstest.reportsPaths
but the filename of the trx is dynamically set by the vstest.console.exe...
Thanks, Jon
Upvotes: 1
Views: 2308
Reputation: 794
I know this topic is a little bit old but I got the same problem than you to import gtest test report into SonarQube.
I've finally found a converter that transforms a gtest test report to the Generic Format. It supports also junit xml format but I did not test by myself. The original script was made by another guy, bloodle, but I forked his repository to migrate to Python 3. All the thanks go to him.
Upvotes: 1
Reputation: 875
I just put **/TestResults/*.trx
in Visual Studio Test Reports Paths
(sonar.cxx.vstest.reportsPaths
) and now it is being loaded correctly... go figure.
Upvotes: 0
Reputation: 51103
The simplest way is converting the test result to XML format. After that you just used the default import functionality.To achieve this, use CoverageCoverter.exe with below code.
class Program
{
static int Main(string[] args)
{
if ( args.Length != 2)
{
Console.WriteLine("Coverage Convert - reads VStest binary code coverage data, and outputs it in XML format.");
Console.WriteLine("Usage: ConverageConvert <sourcefile> <destinationfile>");
return 1;
}
CoverageInfo info;
string path;
try
{
path = System.IO.Path.GetDirectoryName(args[0]);
info = CoverageInfo.CreateFromFile(args[0], new string[] { path }, new string[] { });
}
catch (Exception e)
{
Console.WriteLine("Error opening coverage data: {0}",e.Message);
return 1;
}
CoverageDS data = info.BuildDataSet();
try
{
data.WriteXml(args[1]);
}
catch (Exception e)
{
Console.WriteLine("Error writing to output file: {0}", e.Message);
return 1;
}
return 0;
}
}
More detail info and ways please refer Publishing vstest results? & MSTest Plugin
Upvotes: 0