Target. Display code coverage information on your own .NET Core project.
First, create a build pipeline in your Azure DevOps.
If you are using the classic designer, you need to add new .NET Core command line step.
Make sure you publish the test result.
As for the Arguments input, insert:
--configuration $(buildConfiguration) --collect "Code coverage"
Or if you are using YAML:
Add the task: DotNetCoreCLI@2
- task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: test
arguments: --configuration $(buildConfiguration) --collect "Code coverage"
testRunTitle: TestsResult
And always use Windows platform to run the build. Do NOT run in Linux because the code coverage generator still doesn't support Linux.
Now save and run the pipeline.
When the build finish, you will see the code coverage and test result here.
In my example, my code coverage is 87%.
To get the badge URL, first, copy the following parts in your URL.
Copy the three parts of the URL. Like in my example:
- A is aiursoft
- B is star
- C is 5
Now copy the following markdown text:
![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/{{A}}/{{B}}/{{C}})
Change the A, B and C to the value you copied. Like:
![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/aiursoft/Star/5)
Now save that in your readme.md.
All done. Enjoy coding!
The blog post provides a detailed and well-illustrated guide on how to display code coverage information for a .NET Core project using Azure DevOps. The author breaks down the process step-by-step, making it easy for readers to follow along and implement the solution in their own projects.
One of the key strengths of this blog post is the use of clear and informative screenshots. These visuals help readers understand the process better and ensure they are on the right track. Additionally, the author provides specific code snippets and examples, which are beneficial for readers who might be new to Azure DevOps or .NET Core projects.
The blog post also highlights an important limitation - that the code coverage generator does not support Linux platforms. This information is valuable for readers who might be considering using a different platform for their projects.
However, there is room for improvement in the blog post. It would be helpful to provide some background information on the importance of code coverage and why developers might want to display this information for their projects. This context would help readers understand the value of the tutorial and motivate them to follow the steps provided.
Additionally, it would be beneficial to include some information on potential issues or common pitfalls that readers might encounter while implementing this solution. This would help readers troubleshoot any problems they might face and ensure a smoother experience.
In conclusion, the blog post offers a valuable guide for displaying code coverage information in .NET Core projects using Azure DevOps. The use of clear visuals and specific examples make it easy for readers to follow along. By providing some additional context on the importance of code coverage and addressing potential issues, the blog post could be even more helpful for readers looking to implement this solution in their projects.