Questions tagged [pitest]

PIT is a fast bytecode-based mutation testing system for Java.

PIT is a state of the art mutation testing system, providing gold standard test coverage for Java and the jvm. It's fast, scalable and integrates with modern test and build tooling (Gradle, Maven, IntellJ IDEA, Eclipse ...).

What is a mutation?
A mutation is a piece of code added or modified in an application code base.

What is mutation testing?
A mutation (fault) can create side effects or not at all. Those side effects can be detected (ie fault killed) by the application tests suite or not. The more faults killed by the application tests suite, the better the suite is. However, when a fault keeps living, here comes mutation testing.

How does PIT mutation testing work?
It detects whether each statement is meaningfully tested by running unit tests against automatically modified versions of the application code. PIT chooses and prioritises tests based on three factors: Line coverage, Test execution speed and Test naming convention.

More details: http://pitest.org, http://pitest.org/faq

125 questions
29
votes
1 answer

JUnit tests pass but PIT says the suite isn't green

While trying to run a PIT mutation test I get the following error: mutationCoverage failed: All tests did not pass without mutation when calculating line coverage. Mutation testing requires a green suite. The tests run just fine when I do a normal…
Bobby
  • 421
  • 1
  • 4
  • 8
13
votes
1 answer

Mutation not killed when it should be with a method with an auto-injected field

I have the following: public class UnsetProperty extends Command { @Resource private SetProperty setProperty; public String parse(String[] args) { if (args.length != 4) { throw new RuntimeException("Incorrect number…
Madara's Ghost
  • 158,961
  • 49
  • 244
  • 292
9
votes
1 answer

PTTest is failing and not generating mutation coverage

I want to generate mutation test coverage. I am doing POC on PI Test but it is not taking my test classes and failing. I have configured PTTest plugin in pom.xml. I checked the target class package name and target test class package name are correct…
Prithvipal Singh
  • 462
  • 2
  • 8
  • 20
8
votes
1 answer

pitest excludedMethods maven

I am trying to exclude PIT from mutating something I/O methods, such "close" and "flush". Here is my Maven configuration: org.pitest pitest-maven 1.1.3
ric
  • 135
  • 1
  • 10
7
votes
1 answer

PiTest "changed conditional boundary mutation survived" without reason?

I have a small Java 11 example with a JUnit 5 test that results in a pitest result of: changed conditional boundary → SURVIVED Main class: public final class CheckerUtils { private CheckerUtils() { super(); } public static int…
PowerStat
  • 3,252
  • 7
  • 25
  • 47
7
votes
1 answer

Pitest WARNING : Slave exited abnormally due to TIMED_OUT

How should i get rid of this warning and add the timeout constant for pitest? My command is: mvn jacoco:report org.pitest:pitest-maven:mutationCoverage sonar:sonar -Dpitest.timeoutConst=8000 But it throws: WARNING : Slave exited abnormally due to…
Sunil Gulabani
  • 778
  • 1
  • 6
  • 18
7
votes
1 answer

Run Pitest from the command line

According to Pitest's documentation, it seems that this should be simple, but it is giving me some trouble. I should be able to have java -cp \ org.pitest.mutationtest.commandline.MutationCoverageReport \ --reportDir…
DeadEli
  • 813
  • 2
  • 10
  • 26
6
votes
4 answers

Excluding tests from execution by PIT

I have to exclude my integration tests from their execution by PIT. There is an option excludedTestClasses since version 1.3.0. I tried to pass over these tests by the following configration of the Maven plugin of PIT.
Oliver
  • 3,186
  • 4
  • 27
  • 51
6
votes
2 answers

Finding useless unit tests with PIT

Assume we have a code we'd like to test: class C { int doSmth() { return 1; } } Now assume we have 2 unit tests placed within a single class. The 1st one "test everything" while the 2nd one "does…
Bass
  • 4,011
  • 2
  • 26
  • 67
6
votes
1 answer

Sonar Pitest Plugin

I want to integrate some mutation testing to ensure the quality of my junit tests. I want to have the results in the sonar dashboard of my project. The sonar pitest plugin seems to do what I want, but there are some issues with maven 3 and it is…
gontard
  • 25,988
  • 10
  • 86
  • 116
5
votes
2 answers

pit mutation - if ( x !=null ) return null else throw new RuntimeException

I have a method that returns a custom object public MyObject getTheObject(){ ... return muObject; } its unit test checks that the object returned by getTheObject() method is not null @Test public void testGetTheObject(){ ... …
Toseef Zafar
  • 1,195
  • 2
  • 13
  • 39
5
votes
1 answer

Proper setup for pitest-maven report-aggregate goal

folks! I've tried to use the pitest-maven plugin in my Maven / Java project and it is apparently failing to generate an aggregated report (taking into consideration that I have a multi-module project). I gather some information from the official…
Fernando Barbeiro
  • 592
  • 3
  • 9
  • 29
4
votes
3 answers

My PITEST won't run. Coverage generation minion exited abnormally. I need help to configure my pom.xml properly

When running mvn org.pitest:pitest-maven:mutationCoverage, I get the error as follows ( Environment: Windows 10, Maven 3.6.1, Java 11, junit-jupiter 5.4.1, pitest 1.4.7) [ERROR] Failed to execute goal org.pitest:pitest-maven:1.4.7:mutationCoverage…
Øyvind Roth
  • 117
  • 1
  • 8
4
votes
2 answers

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,…
zodac
  • 293
  • 5
  • 19
4
votes
1 answer

PIT testing - need to exclude certain packages from the report

I am trying to generate a PIT Test Coverage Report and I need to exclude a certain package. These are the used configurations : org.pitest
Madiha
  • 105
  • 2
  • 8
1
2 3
8 9