A JUnit extension that generates JFR events.
<dependency>
<groupId>com.github.marschall</groupId>
<artifactId>junit-jfr</artifactId>
<version>0.1.0</version>
<scope>test</scope>
</dependency>
Requires Java 11 based on OpenJDK.
The extension supports the following event types in the "JUnit" category.
- @BeforeAll
- Contains the execution of all
@BeforeAll
methods. - @BeforeEach
- Contains the execution of all
@BeforeEach
methods. - @Test
- Contains the execution of all
@Test
methods. - @AfterEach
- Contains the execution of all
@AfterEach
methods. - @AfterAll
- Contains the execution of all
@AfterAll
methods.
Every event type may also cover some extension methods.
- Add
@JfrProfiled
to your unit test class, see JfrExtensionTest for and example. - Generate a flight recording from your unit tests, eg using
-XX:StartFlightRecording:filename=recording.jfr
-XX:FlightRecorderOptions:stackdepth=128
@JfrProfiled
class ProfiledTests {
@Test
void testMethod() {
// implementation
}
}
Built in JFR support in JUnit 5.7 is much easier to use as it requires only adding the org.junit.platform:junit-platform-jfr
and no additional annotations. However the built in JFR support in JUnit does not generate events for @BeforeAll
, @BeforeEach
, @AfterEach
and @AfterAll
methods.