# SpotBugs on a Test-Only Maven Project
This Gist documents the minimum required for the two ways to integrate SpotBugs on a test-only project:
## Integrating SpotBugs in the build
The following plugin config will run spotbugs against your test code, and fail the build if it finds anything. Run it as follows:
`mvn clean test`
```xml
4.0.0
com.example
spotbugs-test-only
0.0.1
junit
junit
4.13.2
test
com.github.spotbugs
spotbugs-maven-plugin
4.9.8.1
true
test
check
```
## Integrating SpotBugs into project report generation
The following plugin config will generate a spotbugs report against your test code. Note that it requires compiled test code which is generated not in the `compile` phase but the `test-compile` phase that follows it. The `test-compile` phase is part of the `test` phase, so to generate the spotbugs report execute either of the following:
`mvn clean test site` (which will generate the report after compiling and executing your tests)
...or...
`mvn clean test-compile site` (which will generate the report after compiling but _not_ executing your tests)
```xml
4.0.0
com.example
spotbugs-test-only
0.0.1
junit
junit
4.13.2
test
org.apache.maven.plugins
maven-site-plugin
3.21.0
com.github.spotbugs
spotbugs-maven-plugin
4.9.8.1
true
```