Skip to content

marschall/junit-jfr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

a JUnit 5 extension that generates JFR events

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages