question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[pitest-maven] report-aggregate fails due to test dependencies

See original GitHub issue

I run pitmp on my whole project to generate reports for each module. Then I run pitest-maven report-aggregate on a reporting module (dedicated module that has dependencies to all other modules). I get the following error:

[ERROR] Failed to execute goal org.pitest:pitest-maven:1.4.8:report-aggregate (merge-pitest-reports) on project reporting: An error has occurred in PIT Test Report report generation.: /home/---/.m2/repository/commons-beanutils/commons-beanutils/1.9.3/commons-beanutils-1.9.3.jar is not a directory -> [Help 1]

I tried to understand why this is happening so I ran maven in debug mode and debugged pitest-maven. Here is the code that seems wrong to me (in AbstractPitAggregationReportMojo class):

  private List<File> getCompiledDirs(final MavenProject project)
      throws Exception {
    final List<String> sourceRoots = new ArrayList<>();
    for (final Object artifactObj : FCollection
        .filter(project.getPluginArtifactMap().values(), new DependencyFilter(
            new PluginServices(this.getClass().getClassLoader())))) {

      final Artifact artifact = (Artifact) artifactObj;
      sourceRoots.add(artifact.getFile().getAbsolutePath());
    }
    return convertToRootDirs(project.getTestClasspathElements(),
        Arrays.asList(project.getBuild().getOutputDirectory(),
            project.getBuild().getTestOutputDirectory()),
        sourceRoots);
  }

The call to project.getTestClasspathElements() returns the list of test sources but also the list of dependencies. Then in ReportAggregator, the method addCompiledCodeDirectory calls validateDirectory with this code:

    private void validateDirectory(final File directory) {
      if (directory == null) {
        throw new IllegalArgumentException("directory is null");
      }
      // For this method, a non existing directory is valid.
      // It probably needs some special treatment later, but it shouldn't prevent the aggregator to be built.
      if (directory.exists() && !directory.isDirectory()) {
        throw new IllegalArgumentException(directory.getAbsolutePath() + " is not a directory");
      }
    }

It fails here due to dependencies that are jars and not folders.

I think the issue comes from use of getTestClasspathElements(). If you want only directories, it should be getTestCompileSourceRoots() instead.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
aurelien-baudetcommented, Dec 3, 2021

Waiting for @hcoles to merge it

0reactions
hcolescommented, Jan 11, 2022

@dan323 as per my comment on the PR, happy to merge if someone can resolve the conflicts and confirm that it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pitest report-aggregate goal complains about transitive ...
[ERROR] Failed to execute goal org.pitest:pitest-maven:1.5.1:report-aggregate (put-it-together) on project mutationtesting: An error has ...
Read more >
Test Aggregation Across Modules - PIT Mutation Testing
This package has a class called org.pitest.aggregate.ReportAggregator.Builder . This class can be used to programmatically build up an aggregation of reports in ...
Read more >
Error on runningpitest - Google Groups
Shweta Gupta · <plugins> · <plugin> · <groupId>org.pitest</groupId> · <artifactId>pitest-maven</artifactId> · <version>1.5.2</version> · <dependencies> · <dependency>.
Read more >
optaplanner-build-parent : 8.7.0.Final - Maven Central
Instrumentation of classes generated by antlr fails due to exceeding method ... See: https://www.jacoco.org/jacoco/trunk/doc/report-aggregate-mojo.html and ...
Read more >
Real world mutation testing - Cornell CS
If your tests fail then the mutation is killed, if your tests pass then the ... To generate the pit site report, set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found