pitmp-maven-plugin icon indicating copy to clipboard operation
pitmp-maven-plugin copied to clipboard

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

Open aurelien-baudet opened this issue 1 year ago • 0 comments

Characteristics

  • Issue Type: bug
  • Reproducibility: always
  • Severity: major
  • Pitmp updated for pitest 1.13.2 (see https://github.com/STAMP-project/pitmp-maven-plugin/pull/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:

  • https://github.com/hcoles/pitest/issues/323
  • https://github.com/hcoles/pitest/issues/224

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.

aurelien-baudet avatar May 18 '23 13:05 aurelien-baudet