JUnit JFR

A JUnit extension that generates JFR events.

License

License

MIT
Categories

Categories

JUnit Unit Testing
GroupId

GroupId

com.github.marschall
ArtifactId

ArtifactId

junit-jfr
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

JUnit JFR
A JUnit extension that generates JFR events.
Project URL

Project URL

https://github.com/marschall/junit-jfr
Source Code Management

Source Code Management

https://github.com/marschall/junit-jfr

Download junit-jfr

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.marschall/junit-jfr/ -->
<dependency>
    <groupId>com.github.marschall</groupId>
    <artifactId>junit-jfr</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.marschall/junit-jfr/
implementation 'com.github.marschall:junit-jfr:0.1.0'
// https://jarcasting.com/artifacts/com.github.marschall/junit-jfr/
implementation ("com.github.marschall:junit-jfr:0.1.0")
'com.github.marschall:junit-jfr:jar:0.1.0'
<dependency org="com.github.marschall" name="junit-jfr" rev="0.1.0">
  <artifact name="junit-jfr" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.marschall', module='junit-jfr', version='0.1.0')
)
libraryDependencies += "com.github.marschall" % "junit-jfr" % "0.1.0"
[com.github.marschall/junit-jfr "0.1.0"]

Dependencies

provided (1)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.3.2

test (3)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-engine jar 5.3.2
org.junit.platform : junit-platform-launcher jar 1.3.2
org.hamcrest : hamcrest-junit jar 2.0.0.0

Project Modules

There are no modules declared in this project.

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.

Versions

Version
0.1.0