Skip to content

Latest commit

 

History

History
66 lines (49 loc) · 2.28 KB

README.md

File metadata and controls

66 lines (49 loc) · 2.28 KB

JUnit JFR Maven Central Javadocs Build Status

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.

Flight Recording of a JUnit Test

Event Types

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.

Usage

  • 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
  }

}

Comparison with JUnit 5.7 JFR Support

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.