Comments (3)
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:
- The test-classes directory
- The classes directory
- The project dependencies
- Additional classpath elements
https://maven.apache.org/surefire/maven-surefire-plugin/examples/configuring-classpath.html
from test-driven-detectors4findbugs.
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.
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)
- findbugs 2.x HOT 7
- NullPointerException when initializing a BugAccumulator in the detector's constructor HOT 6
- Test "createsFileSystemCodeBaseLocatorForEachJarPathGiven" is failed on Windows HOT 5
- Exception/error messages of DetectorAssert is not informative HOT 1
- missing XFactory interning in test driver HOT 4
- BugMatcher not propagated by Detector --> Detector2 delegation method HOT 2
- DetectorAssert usability problem for multiple matchers HOT 1
- DetectorAssert.addRegistrar(...) has no effect HOT 3
- Compatibility with Findbugs 3 HOT 3
- Using Java 8 lambdas as tested classes
- Make available from Maven Central HOT 3
- Possibly incorrect license listed HOT 1
- RuntimeException: Failed to setup FindBugs dependencies for testing caused by FileNotFoundException HOT 6
- jdk 1.6 HOT 1
- java.lang.ExceptionInitializerError will thrown many times HOT 3
- Support Detector2 interface HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from test-driven-detectors4findbugs.