Issue running code coverage with dotCover in release mode - code-coverage

Has anyone successfully run coverage reporting using dotCover (and ideally TeamCity) while targeting release mode in the application? Here's the error message I received (this configuration works in debug mode):
Generate dotCover report (6s)
[09:53:44][Generate dotCover report] Started dotCover: E:\BuildAgent3\tools\dotCover\dotCover.exe report F:\TCAgents\ag3temp\buildTmp\dotcover3521342814066873775.xml
[09:53:44]
[Generate dotCover report] Output: JetBrains dotCover Console Runner v2.0.425.62. Copyright (c) 2009-2012 JetBrains s.r.o. All rights reserved.
[JetBrains dotCover] Report generation started [8/29/2012 9:53:43 AM]
[JetBrains dotCover] Report generation finished [8/29/2012 9:53:43 AM]
[Generate dotCover report] dotCover exited with code: 0
Generate dotCover HTML report
[Generate dotCover HTML report] No source files were found under the build checkout directory F:\TCAgents\ag3work\724608d32a4f6354. No source files will be included in dotCover report as source code of classes.
We would like to produce one set of compiled artifacts to pass through the delivery pipeline (including deployment). We didn't run into this problem with NCover - it was able to produce coverage on our release build.
Note: .pdb files are being generated in release mode

According to the logs, snapshot was taken normally and coverage statistics must be presented. Looks like source code build and coverage analysis are in different build configurations. You can either put build and coverage analysis in a single configuration or configure source code mapping by TC-parameter
dotNetCoverage.dotCover.source.mapping (format: path1 => path2)
Current checkout dir can be specified as % teamcity.build.checkoutDir%

Related

Integration of tSQLt + SSDT into Jenkins

I am using SQL Server 2017 and Visual Studio 2019 Community edition.
I have created my first SSDT project and configured it in Jenkins and I am facing issues while deploying it before running my tSQLt test cases.
Please refer to the link which I used to configure everything:
https://the.agilesql.club/2017/03/sql-server-continuous-deployment-in-a-box/#comment-4976546606
PS: Have made changes in related ps files for paths of msbuild and other related files as I am using SSDT and Sql server recent versions and above link shows older versions.
Error
I got succeed to build my ssdt project in jenkins but when it tries to run "DeployDacpac.ps1" in "Unit Tests" step it shows success in pipeline steps but actually script shows error like :
C:\Program Files (x86)\Jenkins\workspace\Test12_master>powershell.exe -ExecutionPolicy RemoteSigned -File "C:\Program Files (x86)\Jenkins\workspace\Test12_master/Deploy/DeployDacpac.ps1" -projectPath "C:\Program Files (x86)\Jenkins\workspace\Test12_master" -dacpac "C:\Program Files (x86)\Jenkins\workspace\Test12_master/bin/Debug/DatabaseUT.dacpac" -publishProfile "C:\Program Files (x86)\Jenkins\workspace\Test12_master/DatabaseUT.publishprofile.xml"
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Data.Tools.Utilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Microsoft.Data.Tools.Schema.CommandLineTool.Program.Main(String[] args)
Update: Now after changing path of sqlpackage.exe from my local folder to visual studio...\SQLDB\DAC\140\sqlpackage.exe" deployment works fine. But it shows that tSQLt unit tests step run successfully. Its not showing proper message any test case failed or passed.
Here is some ending result lines from unit test run step:
"...
Installing package 'AgileSQLClub.tSQLtTestAdapter' to 'C:\Program Files (x86)\Jenkins\workspace\Test17_master\Lib'.
CACHE https://api.nuget.org/v3/registration5-gz-semver2/agilesqlclub.tsqlttestadapter/index.json
Package "AgileSQLClub.tSQLtTestAdapter.0.59.0" is already installed.
Microsoft (R) Test Execution Command Line Tool Version 16.6.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 158 test files matched the specified pattern."
It consideres all sps including tSQLt sps above in 158. But no result mentions if any unit test passed or failed.
Please guide.
Instead of SSDT project, I am using batch command to run tsqlt test cases through jenkins. i.e. sqlcmd.
So no need to dig more

SONAR + R# analysis integration for MSBuild projects

I have a problem to integrate SONAR and resharper output.
Here is the process I have :
With JENKINS and SONAR integration (sonar-scanner for ms build), I do not want to use roslyn analysis output but I would like to use R# (resharper) analysis. What I do is :
I run resharper command line tool to analysis a solution.
"E:\Jenkins\tools\JetBrains.ReSharper.CommandLineTools.2018.2.3\InspectCode" "E:\Jenkins\workspace\TPStrings\TPStrings.sln" --project=TPStrings --swea -s=INFO -o="E:\Jenkins\workspace\TPStrings\TPStrings.ReSharperReport.xml"
Convert R# output into sonar output using dotnet-reqube.exe which turns R# output to JSON sonar output.
Start SonarScanner.MSBuild.exe and reference my previous JSON sonar output using externalIssuesReportPaths parameter
Run my build
Delete the roslyn files from MSBUILd analysis so that there are not taken into account by sonar.
End SonarScanner.MSBuild.exe : SonarScanner.MSBuild.exe end
Here is the output I get :
Empty project issue
but R# analysis errors are present :
R# imported rules
Why the project summary not well created with externalIssuesReportPaths?
I am expected to get something like :
Expected result
Thanks for you help.

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?

Unit test not showing up in SonarQube

Using Jenkins I am trying to pass the result of the Nunit task and the OpenCover task to SonarQube.
SonarQube displays properly the test coverage but there is no trace of unit test results.
Here is what I do :
Build Visual Studio project with MSBuild
Batch windows for opencover via nunit
Launch SonarQube scanner
Batch windows for deployement
Here is my actual properties for the Sonar Scanner task:
sonar.projectKey=FC
sonar.projectName=FC
sonar.projectVersion=%SVN_REVISION%
sonar.sources=src
sonar.binaries=build
sonar.exclusions=src/FC.Test/**/*.*
sonar.tests=src/FC.Test
sonar.cs.nunit.reportsPaths=TestResult.xml
sonar.cs.opencover.reportsPaths=reports/opencovertests.xml
I'm using SonarQube 5.6, Jenkins 2.10, SonarQube plugin 2.4.3, OpenCover 4.5 and Nunit 2.6.4
Is there any known problems (compatibility issues...) ?
Note that I tryed to wrap my process with the Prepare and Terminate Sonar analysis tasks but it systematicaly deletes the coverage panel. So i removed it.
EDIT 2017
I stopped doing this way. I understood that the good way to do this was using the SonarQube Scanner for MSBuild which is integrated at the Jenkins's plugin.
The coverage panel was not shown because i didn't configure my quality profiles properly.
But...
I still don't have my tests' result in Sonar.
I checked the absolute path of my report and its parsing by sonarQube : "INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=25ms". I also tryed with a .nunit file. I saw that apply a filter to opencover could help, so I did.
Do you have a clue?
Scanning C# projects requires to use the Sonar Scanner for MSBuild and follow a specific 3 steps process which I guess you don't follow for now. See doc about the 3 steps process at: http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild and http://docs.sonarqube.org/display/SCAN/From+Jenkins
Your properties look correct. Yet they shall not be provided in a sonar properties file but instead in the command line arguments of the MSBuild.SonarQube.Runner.exe begin step, for example:
MSBuild.SonarQube.Runner.exe begin <allMandatoryParameters> /d:sonar.cs.nunit.reportsPaths=TestResult.xml /d:sonar.cs.opencover.reportsPaths=reports\opencovertests.xml
Olivier

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...

Resources