Clover code coverage reports from MsTest results - code-coverage

I have a Bamboo job with a task that runs MSTest against a unit tests dll. The MSTest generates a trx file.
Is there a way to generate code coverage report from the trx file using Clover code coverage tool?

Related

Execute OPA5 test headless and code coverage

I am aware of using karma and phantomjs to run opa5 headless. I want to know if there any other options? Currently I am using grunt to run qunit and Nightwatch for unit and end-to-end tests. I added OPA5 tests and looking for ways to run it headlessly with coverage report which I can publish on TFS(Team Foundation Server)
Please guide.
You also can consider Selenium, check the different of them: Casperjs/PhantomJs vs Selenium.
Regarding test result, you can use trxReporter, related article: CI/CD Pipeline for Angular2 with VSTS.
Regarding Code Coverage, the TFS Code Coverage supports JaCoco and Cobertura (Publish code coverage task) and karma-coverage supports Cobertura format, so you can use cobertura code coverage report.
Related article: Include code coverage report in VSTS, Is Test Adapter mandatory for VSTS? (Apply to TFS)

Code coverage Cobertura report for WCS projects (Websphere Commmerce Server )

Is it possible to create a code coverage Cobertura report and get it published on Sonar Dashboard for Websphere Commmerce Server (WCS) projects ? I understand that the pre-requisite is that the team should have written the Junit test cases but still wondering whether code coverage report is possible to generate ?
Under the assumptions that
a Websphere Commerce Server project is written in Java
the project contains unit tests that are executed during the build
a code coverage report is generated during the run of unit tests and pointed to during the analysis
Then the answer is yes.

OpenCover not generated Nunit result

In our continuous integration process we are using Jenkins, NUnit and OpenCover.
Every Jenkins job runs NUnit and OpenCover, but OpenCover calls the NUnit batch file in order to determine code coverage; therefore NUnit is executed twice.
For example we have a first (simplified) batch:
nunit-console-x86 [PathToTestAssemblies] /xml=NunitResult.xml /noshadow /nodots /process=Separate
And we have a second batch for OpenCover:
OpenCover.Console.exe -target:"NUnit.bat" -output:"./OpenCoverResults.xml" -register -targetdir:".\bin" -coverbytest:*.dll
The problem is that OpenCover does not provide NUnit result (The NunitResult.xml file in my previous command). So in order to have less test time for every Jenkins job we want to get back the NUnit result or find a way to have the following features with OpenCover in the Jenkins job web page:
Latest Tests result from every Jenkins job, so it is easy for a developer to see the latest result.
Test result trend
Is there a way to have both NunitResult and OpenCover results from an single run of NUnit?
I finally found were was the NUnitResult.xml file. In fact it was in the folder were I put all test assemblies (ex: bin) while the Nunit batch put it at the root location.
I think this is because I use the -targetdir args with "bin" to indicate OpenCover were are my assemblies.

Generate two coverage reports in a single jenkins build

I have a Jenkins build which build all my java/angularJS project. It launch testNG tests for the java part and karma tests for the javascript part. So I can generate one testNG report (for java) and one junit report (for karma test) in my Jenkins build. This is working very well.
Until now, I used cobertura to report the coverage of my java tests. But now I would like to add also a coverage report for my karma tests (generated by Istanbul with cobertura type). The problem is that, in Jenkins, I'm allowed to generate only one coverage report in a build (I can't add more that one 'publish cobertura coverage report' post build action). So how can I have these two coverage reports in a single Jenkins build?
There's a nice plugin called HTML Publisher Plugin. You can generate HTML coverage reports and publish as much reports as you want under different titles in one Jenkins project.
For example I generate html reports using karma+istanbul and then publish them to Jenkins.
On JUnit xml report files. You should import JUnit once enumerating all files probably from different directories but you can differentiate them with proper package names inside files.
If I'm right, you can't use, as a post build action, the same plug-in twice( note that I'm not really sure). I faced this problem when I worked as Jenkins plug-in developer for a company and the solution was to use a plug-in that make the same thing.
For example: for JUnit reports there is an official JUnit plugin and also XUnit. For my problem it was simple.
So, maybe you can find a plug-in that do the same thing as Cobertura or you can change the output format of the java coverage or karma coverage. For example, for java you can use EclEmma or Jacoco...

JaCoCo Selenium test code coverage and import to Sonar using Ant

I am running Sonar task through Ant, triggered by Jenkins in RHEL environment. I am successfully using Cobertura for Junit code coverage and Surefire for reporting. Sonar imports the Surefire reports fine.
However, now I am running Selenium tests using Ant in Jenkins. I would like to report code coverage and test results to Sonar. Apparently I need the JaCoCo plugin which analyses code coverage and reports tests. I presume like for unit tests, Jenkins does the job and Sonar only imports the reports into its own repository.
I am puzzled on how to actually do this. The web page http://www.sonarsource.org/measure-coverage-by-integration-tests-with-sonar-updated/ references to the JaCoCo page http://www.eclemma.org/jacoco/trunk/doc/ant.html. I am not sure what the steps are to be done. Do I need the coverage target? Should I only start the agent? Where in Ant do I start the agent? Do I need to dump stuff?
I really appreciate all the help I can get, thanks :)
Sonar 3.3 has a new feature for combine code coverage metrics generated by both unit tests and integration tests. This is done by using two properties to detail the two different report files generated by the jacoco too:
#Tells Sonar where the unit tests code coverage report is
sonar.jacoco.reportPath=reports/jacoco/jacoco-ut.exec
#Tells Sonar where the integration tests code coverage report is
sonar.jacoco.itReportPath=reports/jacoco/jacoco-it.exec
The Sonar examples project has an integration test example for ANT:
https://github.com/SonarSource/sonar-examples/tree/master/projects/code-coverage/it/ant/it-jacoco-ant
Unfortunately it doesn't give an example of running the actual tests, instead it just shows how to configure an ANT build to load data.
Finally the Sonar documentation has more details with links to the example projects.

Resources