JUnit 4 JFR
A JUnit extension that generates JFR events.
<dependency>
<groupId>com.github.marschall</groupId>
<artifactId>junit4-jfr</artifactId>
<version>0.1.0</version>
<scope>test</scope>
</dependency>
Requires Java 11 based on OpenJDK.
If you can migrate to JUnit 5 and marschall/junit-jfr as it offers much higher fidelity.
Usage
- Add a
JfrMethodRule
to your unit test class, see JfrMethodRuleTest for and example. - Generate a flight recording from your unit tests, eg using
-XX:StartFlightRecording:filename=recording.jfr
-XX:FlightRecorderOptions:stackdepth=128
public class ProfiledTest {
@Rule
public JfrMethodRule jfr = new JfrMethodRule();
@Test
public void testMethod() {
// implementation
}
}