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
@BeforeAllmethods. - @BeforeEach
- Contains the execution of all
@BeforeEachmethods. - @Test
- Contains the execution of all
@Testmethods. - @AfterEach
- Contains the execution of all
@AfterEachmethods. - @AfterAll
- Contains the execution of all
@AfterAllmethods.
Every event type may also cover some extension methods.
- Add
@JfrProfiledto 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.
