Reputation: 23
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.
Upvotes: 2
Views: 2703
Reputation: 113
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.
Upvotes: 0
Reputation: 5010
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
Upvotes: 4