"No mutations found" error when running pitmp on multi-module project with a module with only tests (no source code)
aurelien-baudet opened this issue · 0 comments
Characteristics
- Issue Type: bug
- Reproducibility: always
- Severity: major
- Pitmp updated for pitest 1.13.2 (see #58)
- pitest 1.13.2
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
- Create a maven project with child
module-a
and childmodule-b
- Add dependency to
module-b
inmodule-a
- Add some code and tests in
module-b
(Example
with methodsfoo
,bar
andExampleTest
that testsfoo
method only) - Add only tests in
module-a
that test code ofmodule-b
(CrossModuleTest
that testsbar
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.