Azure devops cant open the code coverage file - azure-devops

Hi guys i have a problem with my code coverage of my azure pipeline. When the CI gets trigged for the master branch the agent has a job to test the .net core. When i use this test i have to configure the route and also enable the code coverage. After the CI has been done it ended succesfully and i can download a file with the code coverage. The problem i have is i cant open this file, not with visual studio or anything else. Aynone that knows how i can fix this problem and maby i didnt configure it right?
Picture of my settings:
picture of the file
picture of the error https://i.stack.imgur.com/fxqdI.png

Seems you are using the wrong configuration. I'm afraid --collect"Code coverage" will not work.
You could add a .NET core test task and add /p:CollectCoverage=true argument then use report generate task for adding code coverage reports.
More detail steps, please refer below tutorials:
ASP.NET Core code coverage reports on Azure DevOps
Azure DevOps, unit testing and code coverage with .Net Core

To generate code coverage please follow this steps
Restore nuget packages
Build the app
Run unit tests (You need to add nuegte package to test projects -> coverlet.collector to use 'XPlat Code Coverage')
Install report generator
Run report generator
Publish code coverage

Related

Control code coverage attachments in Azure DevOps

In a multi-stage, yaml configured CI pipeline that builds in Windows and Linux via matrix strategy I'm generating:
A .cobertura.xml file in Linux os, used to produce an aggregated report via ReportsGenerator that is accesible from coverage tab in AzureDevops. I'm explicitly using PublishCodeCoverageResults in this os.
A .coverage file in Windows os, to feed SonarCloud with coverage data. I'm not using PublishCodeCoverageResults in this os.
My issue is that .coverage file overrides the expected report in coverage tab, allowing me to download it rather than seeing the report. How can I avoid that? Is there any way to get rid of that attachment to properly show the report?
If I don't run the Windows part, the report is shown as expected.
If I do it, I get this rather than the report.
I've tried removing .coverage files at the end of the pipeline, but the 'attachment' in coverage tab stays there.
As far I understood you want to have download avialble instead of displaying code coverage like this:
But your code coverage is also available as an artifact:
So you can still download it:
Does it help you somehow?
Answered here:
This is not a bug and the behavior is as designed as the .coverage
report is given precedence over other reports.
My guidance would be to stop publishing the test run as part of the
dotnet task in windows. There is an option to do so.
Copy the trx and coverage files out to separate locations. Upload the
trx file using the publish test results task but make sure the
coverage file is not available for this publish.

Need clarification- Can we build CI CD pipeline using Jenkins where my development code written is in C# and automation code is java eclipse

Need clarification- Can we build CI CD pipeline using Jenkins where my development code written is in C# and automation code is java eclipse
Requirement :
1. Whenever developer will commit the code then new Build should be generated
2. It should run unit test and smoke suite
3. Once Testing smoke suite passed it should show build passed else build should be failed
Can we achieve it using Jenkins. I have concerns like my development and automation code in two different language. In order to build pipeline do we need to have dev and test code in the same repository
Thanks in advance . Please suggests me
I am in exploration phase.
I need help in configuration. I don't think any code will require for this.

How to get Roslyn Analizer results in VSTS Build Definition?

I'm working on DevSecOps. Related to that, I want to secure my application with the help of Roslyn Analyzer. For that I created an MVC Web Application along with custom ruleset in Visual Studio and it's working fine with outputs clearly.
But, when I tried to do same thing with the help of VSTS Build task in my Build Definition in VSTS account. By referring the link, I known that with the help of MSBuild task we can get the Roslyn Analyser results by default. But I didn’t get the results of Roslyn Analyzer results after running my Build Definition. Can you suggest me to “How to overcome this situation”?
If that works locally when run msbuild in command line, then you can try below items to narrow down the issue:
Add a command line task to run the msbuild command line script
directly.
Change another hosted agent.
Deploy an private agent on your dev machine, then check if that works
with the private agent.
You can also reference below articles to troubleshoot the issue:
Using, configuring and distributing Roslyn analysers in teams
Running Code Analyzers on Build Server

How to enable the code coverage view on VSTS?

My team uses VSTS with hosted agents and a Visual Studio Test build task to run all tests and produce code coverage. However the tab Code coverage remains empty afterwards, only showing a link to download the *.coverage file.
I actually expect the code coverage results to be shown, with tables and graphs which projects are tested and it's respective coverage.
We are using the Visual Studio Test build task to test net461 assemblies with the Code Coverage enabled checked.
Somewhat related are both this and this issue, but not entirely, because we are just using MSTest Framework with built-in Visual Studio Test build task, which (I understand) should also automatically publish the code coverage results.
Am I missing something to get this Code coverage view working? Thanks!!
In Code coverage Tab, you need to use Publish Code Coverage Results task to show tables and graphs there.
While for Publish Code Coverage Results task, it only supports Code Coverage data in Jacoco or Cobertura formats. So the result of the *.coverage file can not be shown by tables and graphs in Code coverage Tab.
More details, you can refer the blog Browse Code Coverage reports and the issue How to publish the code coverage result with a .coverage file.

Fail a Build if Code Coverage is Low in Visual Studio Online

I'm trying to fail builds in Visual Studio Online when Code Coverage is below a threshold.
Is there anyway to do it under Visual Studio Online or I have to do it using the XAML Build Definitions.
It is possible to control build result with code coverage percentage result in both vNext build system and XAML build.
In vNext build, you need to add the PowerShell step in the build definition, and run one PowerShell script to determine whether the build failed or succeed. Check this blog for the details of the PowerShell script: http://blogs.msdn.com/b/tfssetup/archive/2015/11/06/controlling-build-result-with-code-coverage-percentage-using-build-vnext.aspx
If you work with one XAML build, you need to create a custom build activity in which contains the logic to fail or pass a build based on code coverage result. Then include to use the build activity in the build definition. See: http://blogs.msdn.com/b/tfssetup/archive/2015/11/06/controlling-build-result-based-on-code-coverage-percentage-for-xaml-builds.aspx
My preferred method is to use the standard XAML build process in Azure DevOps pipeline. Use the code analysis task to fail the build if coverage is below a threshold.
See: https://learn.microsoft.com/en-us/archive/blogs/tfssetup/controlling-build-result-based-on-code-coverage-percentage-for-xaml-builds