https://github.com/marschall/junit-jfr
a JUnit 5 extension that generates JFR events
https://github.com/marschall/junit-jfr
java-flight-recorder junit junit-5 junit5
Last synced: about 1 month ago
JSON representation
a JUnit 5 extension that generates JFR events
- Host: GitHub
- URL: https://github.com/marschall/junit-jfr
- Owner: marschall
- Created: 2018-12-09T18:38:06.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-17T17:35:46.000Z (over 4 years ago)
- Last Synced: 2025-03-27T02:43:12.656Z (about 2 months ago)
- Topics: java-flight-recorder, junit, junit-5, junit5
- Language: Java
- Homepage:
- Size: 440 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
JUnit JFR [](https://maven-badges.herokuapp.com/maven-central/com.github.marschall/junit-jfr) [](https://www.javadoc.io/doc/com.github.marschall/junit-jfr) [](https://travis-ci.org/marschall/junit-jfr)
=========A JUnit extension that generates JFR events.
```xml
com.github.marschall
junit-jfr
0.1.0
test```
Requires Java 11 based on OpenJDK.

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](https://github.com/marschall/junit-jfr/blob/master/src/test/java/com/github/marschall/junit/jfr/JfrExtensionTest.java) for and example.
* Generate a flight recording from your unit tests, eg using
```
-XX:StartFlightRecording:filename=recording.jfr
-XX:FlightRecorderOptions:stackdepth=128
```
```java
@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.