GithubHelp home page GithubHelp logo

PluginDoesntContainMetadataException because the wrong findbugs.xml is found when looking for the core plugin about test-driven-detectors4findbugs HOT 3 OPEN

tim-group avatar tim-group commented on July 4, 2024
PluginDoesntContainMetadataException because the wrong findbugs.xml is found when looking for the core plugin

from test-driven-detectors4findbugs.

Comments (3)

VsevolodGolovanov avatar VsevolodGolovanov commented on July 4, 2024

The problem is probably that the target/classes path is the first on classpath.

This is easily fixed in Eclipse by manipulating the Debug configuration, then the tests run successfully.

But the question remains as to how to fix the order in Maven. I'm using maven-surefire-plugin:

The Surefire plugin builds the test classpath in the following order:

  1. The test-classes directory
  2. The classes directory
  3. The project dependencies
  4. Additional classpath elements

https://maven.apache.org/surefire/maven-surefire-plugin/examples/configuring-classpath.html

from test-driven-detectors4findbugs.

VsevolodGolovanov avatar VsevolodGolovanov commented on July 4, 2024

Moved the classes directory to the end of surefire classpath like this:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <!-- disable adding classes to classpath by adding test-classes again -->
        <classesDirectory>${project.build.testOutputDirectory}</classesDirectory>
        <!-- now add classes to the end of classpath -->
        <additionalClasspathElements>
            <additionalClasspathElement>${project.build.outputDirectory}</additionalClasspathElement>
        </additionalClasspathElements>
    </configuration>
</plugin>

But now all tests result in the error:

java.lang.NullPointerException: null
    at edu.umd.cs.findbugs.DetectorToDetector2Adapter.visitClass(DetectorToDetector2Adapter.java:72)
    at com.youdevise.fbplugins.tdd4fb.DetectorRunner$Singleton.doRunDetectorOnClass(DetectorRunner.java:247)
    at com.youdevise.fbplugins.tdd4fb.DetectorRunner$Singleton.access$000(DetectorRunner.java:70)
    at com.youdevise.fbplugins.tdd4fb.DetectorRunner.runDetectorOnClass(DetectorRunner.java:286)
    at com.youdevise.fbplugins.tdd4fb.DetectorAssert.assertNoBugsReported(DetectorAssert.java:107)
    at com.youdevise.fbplugins.tdd4fb.DetectorAssert.assertNoBugsReported(DetectorAssert.java:98)
    at my.company.MyTest$Subtest._(MyTest.java:79)

Looking at the DetectorToDetector2Adapter.visitClass the issue is the null value of the analysisCache thread local. That's because I have this surefire configuration in the parent pom:

<parallel>classes</parallel>
<threadCount>4</threadCount>
<perCoreThreadCount>true</perCoreThreadCount>

I disabled it at the detector project level by overriding:

<parallel>none</parallel>

Now tests pass successfully when launching via Maven.

When launching tests from Eclipse still need to tweak the classpath manually though. m2e won't take the surefire trickery into account.

from test-driven-detectors4findbugs.

VsevolodGolovanov avatar VsevolodGolovanov commented on July 4, 2024

I suggest using this task to document how to use tdd4fb with Maven: make classes last on classpath; disable parallel test execution.

from test-driven-detectors4findbugs.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.