Pitest mutation coverage : No mutations found ERROR

1,573 views
Skip to first unread message

Hamza

unread,
Jul 12, 2021, 6:15:41 AM7/12/21
to PIT Users

Hello everyone , I really wish to use PITEST for mutation coverage, but I don't know why I get this error all the time and whatever I do :

[ERROR] Failed to execute goal org.pitest:pitest-maven:1.4.8:mutationCoverage (pitest) on project 2: Execution pitest of goal org.pitest:pitest-maven:1.4.8:mutationCoverage failed: No mutations found. This probably means there is an issue with either the supplied classpath or filters.

[ERROR] See http://pitest.org for more details.

Can you please help me with this, you can find my pom.xml below, and thank you for your answers.

pom.xml

Henry Coles

unread,
Jul 12, 2021, 9:03:15 AM7/12/21
to pitu...@googlegroups.com
You have set the globs for the target classes set incorrectly. The filter should match the packages in your project eg "com.example.*"

If you update to a recent version of pitest (1.6.7 is the latest) you can omit this config entirely, the plugin will scan the project and determine which classes to mutate automatically.

--
You received this message because you are subscribed to the Google Groups "PIT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pitusers+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pitusers/fe63da60-e6cf-4014-9c04-cb0f659e6de7n%40googlegroups.com.

Hamza

unread,
Jul 12, 2021, 1:33:19 PM7/12/21
to PIT Users
Thank you for your answer, but I tried to use Pitest 1.6.7 and I get the same error message with the pom.xml below ...
Do you have any ideas why this doesn't work ?
pom.xml

Henry Coles

unread,
Jul 13, 2021, 3:30:20 AM7/13/21
to pitu...@googlegroups.com
A common mistake is to run pitest without ensuring the code and tests are compiled first. Make sure you run mvn test first, or bind pitest to the maven test phase.

Hamza

unread,
Jul 14, 2021, 2:53:57 AM7/14/21
to PIT Users
I run mvn test first, and I use like you can see in the second pom.xml the line :  <phase>test</phase> to bind pitest ...
I still have this message below and I dont understand why I still get 0 mutations ...?

[...]
[INFO] Mutating from /home/hamza/Bureau/Test_Mutationnel/2/target/classes
[INFO] Defaulting target classes to match packages in build directory
[INFO] Defaulting target tests to match packages in test build directory
08:48:23 PIT >> INFO : Verbose logging is disabled. If you encounter a problem, please enable it before reporting an issue.
08:48:24 PIT >> INFO : Incremental analysis reduced number of mutations by 0
08:48:24 PIT >> INFO : Created  0 mutation test units in pre scan
[...]
Failed to execute goal org.pitest:pitest-maven:1.6.7:mutationCoverage (default-cli) on project 2: Execution default-cli of goal org.pitest:pitest-maven:1.6.7:mutationCoverage failed: No mutations found. This probably means there is an issue with either the supplied classpath or filters.
Message has been deleted

Hamza

unread,
Jul 14, 2021, 3:53:50 AM7/14/21
to PIT Users

You can find bellow my little project on my Google Drive (It content one Classe and one TestClasse) , If anyone can run pitest and generate mutations and a pit-report, it will help me a lot ... Thank you !

Henry Coles

unread,
Jul 14, 2021, 11:10:33 AM7/14/21
to pitu...@googlegroups.com
This project is a little strange, the classes are in the default package, but have been placed on disk on a directory named '2'

src/main/java/2
src/test/java/2

I have no idea how that is working. '2' is not a valid package name, and it seems that the compiler is therefore ignoring it and treating the files as if they had been placed directly into src/main.

I'd highly recommend not putting your code in package default. If you do then pitest's auto scan will not work and you'll have to list the classes you want to mutate individually. If you move the classes into a proper package then the autoscan will work and pitest will find code to mutate.

On Wed, 14 Jul 2021 at 08:53, Hamza <hamz...@gmail.com> wrote:

You can find bellow my little project on my Google Drive (It content one Classe and one TestClasse) , If anyone can run pitest and generate mutations and a pit-report, it will help me a lot ... Thank you !

--
You received this message because you are subscribed to the Google Groups "PIT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pitusers+u...@googlegroups.com.

Hamza

unread,
Jul 14, 2021, 9:00:03 PM7/14/21
to PIT Users
Thank you, your answer was very helpful, I specified a package in my classes and it works !
Thank you very much :)
Reply all
Reply to author
Forward
0 new messages