Work around missing JUnit reporting entry support in Gradle
See original GitHub issueI tried to get a basic test running with gradle but it seems like jazzer is trying to instrument the gradle workers and fails somewhere.
$ gradle build
INFO: Instrumented org.gradle.api.internal.tasks.testing.processors.DefaultStandardOutputRedirector$DiscardAction with custom hooks only (took 1 ms, size +0%)
> Task :app:test
DummyFuzzTest > dummyFuzz(FuzzedDataProvider) > dummy.DummyFuzzTest.initializationError FAILED
java.lang.IllegalStateException at AgentInstaller.java:55
Caused by: java.lang.reflect.InvocationTargetException at NativeMethodAccessorImpl.java:-2
Caused by: java.lang.VerifyError at InstrumentationImpl.java:-2
build.gradle
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
testImplementation 'com.code-intelligence:jazzer-api:0.13.0'
testImplementation 'com.code-intelligence:jazzer-junit:0.13.0'
}
application {
// Define the main class for the application.
mainClass = 'dummy.App'
}
tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
App.java
package dummy;
public class App {
public int add(int a, int b) {
return a+b;
}
public static void main(String[] args) {
System.out.println(new App().add(1, 2));
}
}
AppTest.java
package dummy;
import com.code_intelligence.jazzer.api.FuzzedDataProvider;
import com.code_intelligence.jazzer.junit.FuzzTest;
class DummyFuzzTest {
@FuzzTest
void dummyFuzz(FuzzedDataProvider data) {
new App().add(data.consumeInt(), data.consumeInt());
}
}
Any idea how to get this running?
Issue Analytics
- State:
- Created a year ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Support JUnit platform reporting entries #4605 - GitHub
The junit platform TestExecutionListener has a method reportingEntryPublished which is called when tests report additional data. Those entries ...
Read more >Testing in Java & JVM projects - Gradle User Manual
All JVM testing revolves around a single task type: Test. This runs a collection of test cases using any supported test library —...
Read more >JUnit tests missing test resources in classpath - Issue Tracker
So the temporary workaround is to follow Comment #13 . The good news is that IntelliJ 14 provides native support for running Gradle...
Read more >How to use JUnit 5 with Gradle? - Stack Overflow
First, make sure you are using the latest Gradle version, check latest releases at their GitHub releases. If that is for example 4.6,...
Read more >JUnit 5 Tutorial: Running Unit Tests With Gradle
This blog post describes how we can create a Gradle project that can compile and run unit tests which use JUnit 5.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
By default, the tests are only run on a fixed set of inputs stored in the
src/test/resources/dummy/DummyFuzzTestInputs
directory (for your example), plus the empty input. This directory is populated with findings encountered during actual fuzzing runs, which you can start by running the tests with the environment variableJAZZER_FUZZ
set to1
. I tried that on your example and got a finding emitted into the directory that I could then reproduce when running the test withoutJAZZER_FUZZ
set.We actually use JUnit’s reporting entry feature to tell you about all this right in your test logs, which works well with Maven but for some reason doesn’t show up with Gradle.
Attached is the stack trace, thanks for looking into this. In the meanwhile I try the instrument option.
trace.txt