Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-DskipTests Flag not working #750

Closed
cobaasta opened this issue Apr 1, 2020 · 5 comments · Fixed by #972
Closed

-DskipTests Flag not working #750

cobaasta opened this issue Apr 1, 2020 · 5 comments · Fixed by #972

Comments

@cobaasta
Copy link

cobaasta commented Apr 1, 2020

I know there is already a closed issue "Pit Maven Plugin Should Honor -DskipTests Flag #157", but the flag is not working, the command "mvn install -DskipTests" is still executing Pitest.

Affected Version org.pitest.pitest-maven.1.5.1

Btw.: The command "mvn install -DskipPitest" works as expected!

@MosheElisha
Copy link

MosheElisha commented Apr 7, 2020

Try adding:

<configuration>
  <skipTests>${skipTests}</skipTests>
</configuration>

From the docs:

Type: boolean
Default Value: false

honours common skipTests flag in a maven run

marwin1991 added a commit to marwin1991/pitest that referenced this issue Jan 30, 2022
marwin1991 added a commit to marwin1991/pitest that referenced this issue Jan 30, 2022
… additional configuration - restored old test and added new IT test to verify if if -DskipTests works correctly
hcoles added a commit that referenced this issue Jan 30, 2022
#750 -DskipTests Flag should be honoured in a maven run without additional configuration
@rnveach
Copy link
Contributor

rnveach commented Feb 5, 2022

@hcoles @marwin1991
What is the proper way to skip test execution and just run pitest?

Checkstyle was hit with this at checkstyle/checkstyle#11276 (comment) . We removed the skip test property so pitest will run.

When I remove the test goal and run straight mvn clean org.pitest:pitest-maven:mutationCoverage (Note this is also the command listed on https://pitest.org/quickstart/maven/ ), I get the error:

PIT >> INFO : Verbose logging is disabled. If you encounter a problem, please enable it before reporting an issue.
PIT >> INFO : Incremental analysis reduced number of mutations by 0
PIT >> INFO : Created  0 mutation test units in pre scan
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.451 s (Wall Clock)
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.pitest:pitest-maven:1.7.4:mutationCoverage (default-cli) on project checkstyle: Execution default-cli of goal org.pitest:pitest-maven:1.7.4:mutationCoverage failed: No mutations found. This probably means there is an issue with either the supplied classpath or filters.

And when I use mvn clean test org.pitest:pitest-maven:mutationCoverage, it executes the test suite, which pitest will execute again itself as its startup process.

We were trying to avoid double work by excluding test runs and still wanting pitest to do its thing in its own run. We have a completely separate CI run for just tests running alone.

@marwin1991
Copy link
Contributor

@hcoles @rnveach

Maybe we should reopen this issue and discus the problem, because from what I understand piTest should create mutation even if tests are not executed, as @rnveach mentioned above there is an command example in a documentation.

On the other hand we have this special flag skipTests in piTest configuration that everyone was using, and in addition
we have had #157 which was adding this funcionality.

IMO the main question is that: Is command mvn clean org.pitest:pitest-maven:mutationCoverage correct and piTest should generate mutations ?

@marwin1991
Copy link
Contributor

@rnveach

I have made some test and it looks like, mutationCoverage is not compiling test classes and that is why it is not finding mutations.

IMO you should use:

mvn clean test-compile org.pitest:pitest-maven:mutationCoverage

@hcoles
Copy link
Owner

hcoles commented Feb 6, 2022

Yes, the tests won't be compiled if you run just the pitest goal. I've updated the docs now to add test-compile.

Calling the goal directly requires minimal setup, but is not a great way to run pitest. I recomend creating a profile as discussed here.

https://blog.pitest.org/pitest-pr-setup/

This also shows one (slightly hacky) method of avoiding surefire also running, by binding pitest to test-compile instead of test.

A cleaner way is described here, although it requires more boilerplate.

https://stackoverflow.com/questions/14476757/disable-maven-plugins-when-using-a-specific-profile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants