An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

        

JUnit JFR [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.marschall/junit-jfr/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.marschall/junit-jfr) [![Javadocs](https://www.javadoc.io/badge/com.github.marschall/junit-jfr.svg)](https://www.javadoc.io/doc/com.github.marschall/junit-jfr) [![Build Status](https://travis-ci.org/marschall/junit-jfr.svg?branch=master)](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.

![Flight Recording of a JUnit Test](https://raw.githubusercontent.com/marschall/junit-jfr/master/src/main/javadoc/screenshot.png)

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.