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

"No mutations found" error when running pitmp on multi-module project with a module with only tests (no source code) #59

Open
aurelien-baudet opened this issue May 18, 2023 · 0 comments

Comments

@aurelien-baudet
Copy link

Characteristics

Description

I made a pull request to update pitest version. It works well for all modules except one.
The module differs from others since it has no source code but only test sources. The purpose is to do cross-module tests (testing that everything works together).
The issue seems to be related to:

I understand that pitest alone can't work if there is no source code because it doesn't handle multi-module projects.
However, the purpose of pitmp is to allow to run pitest on mutli-module projects and to provide cross-module mutation testing.
Therefore, pitmp should provide correct configuration to pitest by adding classes of other modules.

Steps to reproduce

  1. Create a maven project with child module-a and child module-b
  2. Add dependency to module-b in module-a
  3. Add some code and tests in module-b (Example with methods foo, bar and ExampleTest that tests foo method only)
  4. Add only tests in module-a that test code of module-b (CrossModuleTest that tests bar method)

It fails on module-a with No mutations found. This probably means there is an issue with either the supplied classpath or filters.

This is because pitest tries load source files from directory module-a/target/classes and finds nothing.

Workarounds

I tried to by adding a simple class named Fake in src/main/java of module-a that has a single method just to feign source code so that the directory module-a/target/classes is created. Pitest runs but there is nothing in the report about the tests written in module-a that test code of module-b. This is not what I expected since it should run all tests of module-a, mutate all tests of module-a and also mutate code of dependencies (module-b in this case).

A workaround seems to copy code of all dependencies manually but it should be done by pitmp automatically.

Another possible solution may be to provide a custom CodeSourceFactory extension to provide additional sources in the classpath used by pitest.

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

No branches or pull requests

1 participant