zodac
zodac

Reputation: 357

Possible to fail maven build when any PIT mutation fails, rather than mutation coverage?

I'm using the pitest-maven plugin for my project, and would like to have the maven build fail if there is any mutation that fails.

But I can't see a configuration option that allows me to do that. I can see mutationThreshold and coverageThreshold, but neither of those work.

Ideally, I'd like to use PIT to make sure the tests I've written don't fail any mutations, rather than try to meet a blanket coverage metric.

Is there any way to do that?

Current maven configuration:

<plugin>
    <groupId>org.pitest</groupId>
    <artifactId>pitest-maven</artifactId>
    <version>1.4.0</version>
    <configuration>
        <mutationThreshold>100</mutationThreshold>
    </configuration>
</plugin>

Upvotes: 4

Views: 1771

Answers (2)

C-Otto
C-Otto

Reputation: 5843

Recent versions of pitest (I think 1.6.2+) include a test strength threshold, which only considers code that is covered (i.e., you'd need to add an additional coverage limit if the build should fail for uncovered lines).

   /**
   * Test strength score threshold at which to fail build
   */
  @Parameter(defaultValue = "0", property = "testStrengthThreshold")
  private int                         testStrengthThreshold;

Related:

Upvotes: 1

Darren Forsythe
Darren Forsythe

Reputation: 11411

If you want PIT to fail anytime a mutated test doesn't fail you should only have to set mutationThreshold to 100 meaning complete coverage for all mutations generated.

Upvotes: 2

Related Questions