How to display the Code coverage result using Index.html on VSTS\TFS 2017 Build Summary? - code-coverage

I have a build definition that runs grunt build and generates code coverage results using cobertura tool in cobertura.xml files. The cobertura.xml is used in Publish code coverage result task to publish code coverage result on VSTS build summary.
Along with cobertura.xml file, I have one Index.html file present in same folder which also contains code coverage result in detail. I want to call Index.html file using publish code coverage result task to display code coverage result on build summary instead of cobertura.xml.
I tried doing that by passing the name of index.html along with its path in the publish task but it fails.
Is there any way by which I can display the code coverage using index.html?

Related

TFS Publish Code Coverage Results Task With OpenCover not working

Running Build on TFS 2015 On Permises and my code coverage result Task logs warning saying that coverage data not found. But the xml file was read during the build process.
I have configured the Publish Code Coverage Results like described in the picture:
The logs during build are saying that the file was produced and it was read.
and at the end of all files it says this:
I was expecting to see some code coverage resume data on the build, but that was not the case:
Thanks #DanielMann that reminder helped. Im using openCover and i was not understanding that OpenCover had is own format. Now I change my Cake script to support conversion from openCover to Cobertura.
I added the headers in the cake script like this:
#addin "nuget:?package=Cake.OpenCoverToCoberturaConverter&version=0.1.1.2"
#tool "nuget:?package=OpenCoverToCoberturaConverter&version=0.3.2"
and then after tests executed with sucess I run my code coverage like this:
OpenCover(tool => {
tool.XUnit2($"{testsPath}/**/**/**/**/{projectName}.dll",xUnit2Settings);
}, new FilePath("./OpenCoverCoverageResults.xml"),openCoverSettings);
OpenCoverToCoberturaConverter("OpenCoverCoverageResults.xml", "CoberturaCoverageResults.xml");
ReportGenerator($"CoberturaCoverageResults.xml", $"{outputDir}/Reports");

How to Publish Code Coverage results for Multiple Cobertura.xml file in TFS 2017 Build?

I am using TFS 2017 Update3 and I have a Build definition which runs Grunt build task at two different HTML projects and generates two cobertura.xml files at their respective paths.
To display the code coverage result I have used Publish Code Coverage Results task in my build pipeline but it displays the Code coverage for only 1 project and doesn't display the code coverage result of other Html Project.
I tried using two Publish Code Coverage Results task each pointing to different cobertura.xml files but still it displays the code coverage result for only one project on TFS build summary.
Is there any other ways by which I can publish multiple code coverage result?

Jenkins with MSTest plugin : "mstest xml coverage report file not found"

In my build process, the VsTest.console tests my dll and generates a TestResults\a.trx file. The only parameter I added (more than dll path) is a .runsettings file.
The .trx file is not empty, the xml inside is quite explicit about what have been done. Double-clicking on the trx file opens vs2013 and results + coverage are displayed as it should.
Then, I want to publish the coverage results with jenkins MSTest plugin but it fails because it looks for a file that does not exists. Here are the output log :
MSTest: Processing tests results in file(s) TestResults\a.trx
MSTest: C:\Program Files (x86)\Jenkins\workspace\tepp\TestResults\a.trx
mstest xml coverage report file not found: C:\Program Files (x86)\Jenkins\workspace\tepp\TestResults\mstest-coverage.xml
Should it be better to use the MSTest-runner plugin ?
If not, what did I missed in my build process ?
The problem seems converting MSTest code covarage results in to XML
Have you tried something like TRX2HTML or TRXER ? (The convert them to htm so you can view using publish artifacts plugin)
TRXER
TRX2HTML
I also found this
Can you tell me your build steps?

TFS 2013 does not publish .coverage file on server

I'm developing a quality workflow with TFS 2013 and SonarQube 4.5.1. Everything works fine except one thing: I can't integrate code coverage data from TFS to SonarQube. The problem is that SonarQube needs .trx or .cover files to work.
However, my TFS Build doesn't publish those files. What I've done: I created a CodeCoverage.runsettings file that I mapped on my build with "User defined" type. (With CodeCoverageEnabled it doesn't work either.) In the file CodeCoverage.runsettings, I wrote the following XML tag:
<RunConfiguration>
<ResultsDirectory>.\TestResults</ResultsDirectory>
</RunConfiguration>
in the hope that it would write all the results files in the same directory. The build does indeed create the results directories, but none of them contain .coverage files. However, at the end of the build, in the results page, I can download a .coverage file. Do you know how I can force the writing of this .coverage file on the server? When I run analysis on my local config, the file is created in the test results directory.

How does the Jenkins Cobertura plugin operate to enable source code viewing?

I'm trying to get a build in Jenkins to show a coverage report of a Java unit test run. I can get the report at the high level showing that coverage has occurred at the class and method level, but part of the report where I can view the source code isn't working.
The inputs to the plugin are:
a coverage report in XML
source code
To use the plug in to create a coverage report:
Install Cobertura into Jenkins.
Create a Jenkins job with a post build to generate Cobertura report. In this step you tell it where in the Jenkins workspace to load the coverage report (often named coverage.xml).
Before you run the Jenkins job
The coverage report is created in some way (often by a build script of some kind). The report is often named coverage.xml by most people's build scripts and is placed in the Jenkin's job's workspace.
When running the Jenkins job
When the Jenkins job runs, the Cobertura plugin will read the coverage.xml and use the element to locate the source code. The plugin copies the source code into a cache located at: <Jenkins home>/jobs/<Jenkins job name>/<Cobertura>.
After running the Jenkins job
Read the coverage report by navigating to the Jenkins job that built it. If copying of the source files was successful during running the Jenkins job, you can drill down to the source code and see what lines were covered by the test run. If you can't see the source code level code coverage:
Check the cobertura cache to see if the code is there.
Check the permissions on the cache to see if the Jenkins server process owns that directory and has read, write, execute permission on that directory.
Check the cobertura.xml file and select a element and examine it's "filename" attribute and see if it's path will work as a relative path from the root of the Cobertura cache.
If the cache has old information, delete everything in the cache directory, and re-run the Jenkins job.

Resources