Skip to content

Ability to fail tests if minimum coverage not met #160

Description

@martincostello

Summary

Add the ability to fail the build if a minimum level of coverage is not achieved.

Background and Motivation

Playing around with an existing xunit v3 project to have it use Microsoft Testing Platform, and as part of that work to maintain code coverage I've needed to drop coverlet to instead use the coverage extension.

A missing feature by comparison compared to coverlet is the ability to fail the build if a minimum code threshold isn't met.

In coverlet this is achieved via an MSBuild property in one of two formats:

<!-- Fail if line, method or branch coverage is less than 70 -->
<Threshold>70</Threshold>
<!-- Fail if line, method or branch coverage is less than 70, 75 and 50 respectively -->
<Threshold>70,75,50</Threshold>

Proposed Feature

Add a new feature that can be controlled through the command-line, for example:

--coverage-threshold 75

This could then be customised on a per-test-project basis:

<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --coverage-threshold 42</TestingPlatformCommandLineArguments>

Alternative Designs

None proposed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions