Percentage Coverage on New Code (JustMyCode)

Quality Gate Quality Gates

Same as Percentage Coverage on New Code, on JustMyCode only: new code generated by the compiler or by tools (a new Entity Framework migration...) is not counted. Like the rule New Types and Methods should be tested, it ignores code that is not JustMyCode.

Like Percentage Coverage, it counts the lines coverable by tests: code excluded from coverage is not counted.

Deactivated by default. Activate it, and deactivate Percentage Coverage on New Code, to gate on the code your team writes.

CQLinq source

This quality gate is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.

// <QualityGate Name="Percentage Coverage on New Code (JustMyCode)" Unit="%" />
failif value < 70%
warnif value < 80%
let newMethods = JustMyCode.Methods.Where(m => m.WasAdded() && m.NbLinesOfCode > 0)
let covered    = (double)newMethods.Sum(m => m.NbLinesOfCodeCovered ?? 0)
let notCovered = (double)newMethods.Sum(m => m.NbLinesOfCodeNotCovered ?? 0)
select (covered + notCovered) == 0d ? (double?)null : 100d * covered / (covered + notCovered)

//<Desc>
// Same as *Percentage Coverage on New Code*, on **JustMyCode** only: new
// code generated by the compiler or by tools (a new Entity Framework
// migration...) is not counted. Like the rule *New Types and Methods should
// be tested*, it ignores code that is not JustMyCode.
//
// Like *Percentage Coverage*, it counts the lines coverable by tests: code
// excluded from coverage is not counted.
//
// Deactivated by default. Activate it, and deactivate *Percentage Coverage
// on New Code*, to gate on the code your team writes.
//</Desc>

Quality Gates: all 19 items