---
title: JUnit Jupiter
description: Learn how to integrate Allure with JUnit Jupiter (JUnit 6 and JUnit 5) tests to generate rich, interactive test reports. Follow step-by-step setup, test execution, and report generation guidance.
---

# Getting started with Allure JUnit Jupiter

Info: JUnit 5 is now JUnit Jupiter
This page was previously called **JUnit 5**. JUnit 6 kept the same Jupiter programming model, so the Allure integration is now named after it: **Allure JUnit Jupiter** works with both JUnit 6 and JUnit 5.

- The artifact is `io.qameta.allure:allure-jupiter`. It replaced `allure-junit5` in Allure Java 2.35.1.
- Starting with Allure Java 3.0, the old `allure-junit5` and `allure-junit5-assert` coordinates are **no longer published**. Switch to `allure-jupiter` and `allure-jupiter-assert` before upgrading.
- Allure Java 3.0 requires Java 17 or newer. See [Migrating to Allure Java 3](/docs/guides/allure-java-3-migration/) for all changes.

[![Allure JUnit Jupiter latest version](https://img.shields.io/maven-central/v/io.qameta.allure/allure-jupiter?style=flat "allure-jupiter")](https://mvnrepository.com/artifact/io.qameta.allure/allure-jupiter)

Generate beautiful HTML reports using [Allure Report](https://allurereport.org/) and your [JUnit](https://junit.org/) tests.

Info:
Check out the example projects at [github.com/allure-examples](https://github.com/orgs/allure-examples/repositories?q=visibility%3Apublic+archived%3Afalse+topic%3Aexample+topic%3Ajunit5) to see Allure JUnit Jupiter in action.

## Setting up

To integrate [Allure](https://allurereport.org) into an existing **JUnit Jupiter** project (JUnit 6 or JUnit 5), you need to:

1. Add Allure dependencies to your project.
1. Set up AspectJ for `@Step` and `@Attachment` annotations support.
1. Designate a location for Allure results storage.

Allure Java 3.x and JUnit 6 both require Java 17 or newer.

### Add Allure dependencies

**Maven:**
```xml
<!-- Define the version of Allure you want to use via the allure.version property -->
<properties>
    <allure.version>3.0.0</allure.version>
</properties>

<!-- Add allure-bom to dependency management to ensure correct versions of all the dependencies are used -->
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-bom</artifactId>
            <version>${allure.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<!-- Add necessary Allure dependencies to dependencies section -->
<dependencies>
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-jupiter</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
```

**Gradle (Kotlin):**
```kts
// Define the version of Allure you want to use via the allureVersion property
val allureVersion = "3.0.0"
// ...
dependencies {
    // Import allure-bom to ensure correct versions of all the dependencies are used
    testImplementation(platform("io.qameta.allure:allure-bom:$allureVersion"))
    // Add necessary Allure dependencies to dependencies section
    testImplementation("io.qameta.allure:allure-jupiter")
}
```

**Gradle (Groovy):**
```groovy
// Define the version of Allure you want to use via the allureVersion property
def allureVersion = "3.0.0"

dependencies {
    // Import allure-bom to ensure correct versions of all the dependencies are used
    testImplementation platform("io.qameta.allure:allure-bom:$allureVersion")
    // Add necessary Allure dependencies to dependencies section
    testImplementation "io.qameta.allure:allure-jupiter"
}
```

### Configure AspectJ

Allure leverages AspectJ for the functionality of `@Step` and `@Attachment` annotations. Additionally, some framework integrations (such as [allure-assertj](https://mvnrepository.com/artifact/io.qameta.allure/allure-assertj)) rely on AspectJ integration to function correctly.

**Maven:**
```xml
<!-- Define the version of AspectJ -->
<properties>
    <aspectj.version>1.9.25</aspectj.version>
</properties>

<!-- Add the following options to your maven-surefire-plugin -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.2.3</version>
    <configuration>
        <argLine>
            -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
        </argLine>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>${aspectj.version}</version>
        </dependency>
    </dependencies>
</plugin>
```

**Gradle (Kotlin):**
```kts
// Define the version of AspectJ
val aspectJVersion = "1.9.25"

// Define configuration for AspectJ agent
val agent: Configuration by configurations.creating {
    isCanBeConsumed = true
    isCanBeResolved = true
}

dependencies {
    // Add aspectjweaver dependency
    agent("org.aspectj:aspectjweaver:${aspectJVersion}")
}

// Configure javaagent for test execution
tasks.test {
    jvmArgs = listOf(
        "-javaagent:${agent.singleFile}"
    )
}
```

**Gradle (Groovy):**
```groovy
// Define the version of AspectJ
def aspectJVersion = '1.9.25'

// Define configuration for AspectJ agent
configurations {
    agent {
        canBeResolved = true
        canBeConsumed = true
    }
}

dependencies {
    // Add aspectjweaver dependency
    agent "org.aspectj:aspectjweaver:$aspectJVersion"
}

// Configure javaagent for test execution
test {
    jvmArgs = [ "-javaagent:${configurations.agent.singleFile}" ]
}
```

### Specifying Allure Results location

Allure, by default, saves test results in the project's root directory.
However, it is recommended to store your test results in the build output directory.

To configure this, create an `allure.properties` file and place it in the test resources directory of
your project, which is typically located at `src/test/resources`:

**Maven:**
```properties
allure.results.directory=target/allure-results
```

**Gradle (Kotlin):**
```properties
allure.results.directory=build/allure-results
```

**Gradle (Groovy):**
```properties
allure.results.directory=build/allure-results
```

### Run tests

Run your JUnit tests the same way as you would run them usually. For example:

For Gradle:

**MacOS/Linux:**
```bash
./gradlew test
```

**Windows:**
```bash
gradlew test
```

For Maven:

**MacOS/Linux:**
```bash
./mvnw verify
```

**Windows:**
```bash
mvnw verify
```

After running the tests, Allure will gather the test execution data and store it in the `allure-results` directory.
You can then generate an HTML report from these results using Allure's reporting tools.

### Generate a report

Finally, convert the test results into an HTML report. This can be done by one of two commands:

- `allure generate` processes the test results and saves an HTML report into the `allure-report` directory. To view the report, use the `allure open` command.

- `allure serve` creates the same report as `allure generate`, then automatically opens the main page of the report in a web browser.

## Optional: report JUnit assertions as steps

Add the `allure-jupiter-assert` dependency if you want each individual `Assertions.*` call to appear as a nested step in the Allure report. This makes assertion failures easier to pinpoint when multiple assertions run in one test.

**Maven:**
```xml
<dependency>
    <groupId>io.qameta.allure</groupId>
    <artifactId>allure-jupiter-assert</artifactId>
    <scope>test</scope>
</dependency>
```

**Gradle (Kotlin):**
```kts
testImplementation("io.qameta.allure:allure-jupiter-assert")
```

**Gradle (Groovy):**
```groovy
testImplementation "io.qameta.allure:allure-jupiter-assert"
```

AspectJ must already be configured (see [Configure AspectJ](#configure-aspectj)) for `allure-jupiter-assert` to work.

## Writing tests

The Allure JUnit Jupiter integration not only collects the data provided by JUnit's standard features, but also provides additional features for writing even better tests. This section lists the most notable ways to improve your tests, using both JUnit's and Allure JUnit Jupiter's features.

With Allure JUnit Jupiter, you can:

- provide [description, links and other metadata](#specify-description-links-and-other-metadata),
- [organize tests](#organize-tests) into hierarchies,
- divide the test into smaller, easier-to-read [test steps](#divide-a-test-into-steps),
- describe parameters used when running [parametrized tests](#describe-parametrized-tests),
- make the test save [screenshots and other files](#attach-screenshots-and-other-files) during execution,
- [select which tests to run](#select-tests-via-a-test-plan-file) via a test plan file,
- provide arbitrary [environment information](#environment-information) for the whole test report.

### Specify description, links and other metadata

There is a lot of [metadata](/docs/v2/readability/#description-links-and-other-metadata) you can add to each test so that it would appear in the report. See the [reference](/docs/junit-jupiter-reference/#metadata) for more details.

For each of the metadata fields, there are two ways to assign it: via an annotation before a test method or via a method call inside a test method's body. The second way is called “dynamic”, because it allows you to construct strings and other values at runtime before passing to the methods. Note, however, that it is highly recommended to assign all metadata as early as possible. Otherwise, there is a risk of the test failing before having all metadata set, which is bad for the test report's readability.

**Annotations API:**
```java
import io.qameta.allure.Description;
import io.qameta.allure.Issue;
import io.qameta.allure.Link;
import io.qameta.allure.Owner;
import io.qameta.allure.Severity;
import io.qameta.allure.TmsLink;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static io.qameta.allure.SeverityLevel.*;

class TestMyWebsite {

    @Test
    @DisplayName("Test Authentication")
    @Description("This test attempts to log into the website using a login and a password. Fails if any error happens.\n\nNote that this test does not test 2-Factor Authentication.")
    @Severity(CRITICAL)
    @Owner("John Doe")
    @Link(name = "Website", url = "https://dev.example.com/")
    @Issue("AUTH-123")
    @TmsLink("TMS-456")
    void testAuthentication() {
        // ...
    }
}
```

**Runtime API:**
```java
import io.qameta.allure.Allure;
import org.junit.jupiter.api.Test;

class TestMyWebsite {

    @Test
    void testAuthentication() {
        Allure.getLifecycle().updateTest(result -> result.setName("Test Authentication"));
        Allure.description("This test attempts to log into the website using a login and a password. Fails if any error happens.\n\nNote that this test does not test 2-Factor Authentication.");
        Allure.label("severity", "critical");
        Allure.label("owner", "John Doe");
        Allure.link("Website", "https://dev.example.com/");
        Allure.issue("AUTH-123", "https://example.com/issues/AUTH-123");
        Allure.tms("TMS-456", "https://example.com/tms/TMS-456");
        // ...
    }
}
```

### Organize tests

As described in [Improving navigation in your test report](/docs/v2/navigation/), Allure supports multiple ways to organize tests into hierarchical structures. Allure JUnit Jupiter provides functions to assign the relevant fields to tests either by adding annotations or “dynamically” (same as for the [metadata fields](#specify-description-links-and-other-metadata)).

To specify a test's location in the [behavior-based hierarchy](/docs/v2/navigation/#behavior-based-hierarchy):

**Annotations API:**
```java
import io.qameta.allure.Epic;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test;

class TestMyWebsite {

    @Test
    @Epic("Web interface")
    @Feature("Essential features")
    @Story("Authentication")
    void testAuthentication() {
        // ...
    }
}
```

**Runtime API:**
```java
import io.qameta.allure.Allure;
import org.junit.jupiter.api.Test;

class TestMyWebsite {

    @Test
    void testAuthentication() {
        Allure.epic("Web interface");
        Allure.feature("Essential features");
        Allure.story("Authentication");
        // ...
    }
}
```

To specify a test's location in the [suite-based hierarchy](/docs/v2/navigation/#suite-based-hierarchy):

```java
import io.qameta.allure.Allure;
import org.junit.jupiter.api.Test;

class TestMyWebsite {

    @Test
    void testAuthentication() {
        Allure.label("parentSuite", "Tests for web interface");
        Allure.suite("Tests for essential features");
        Allure.label("subSuite", "Tests for authentication");
        // ...
    }
}
```

A test's location in the [package-based hierarchy](/docs/v2/navigation/#package-based-hierarchy) is defined by the fully qualified names of the classes they are declared in, with common prefixes shown as parent packages.

### Divide a test into steps

Allure JUnit Jupiter provides three ways of [creating steps and sub-steps](/docs/steps/): “annotated steps”, “lambda steps” and “no-op steps”, see the [reference](/docs/junit-jupiter-reference/#test-steps).

**Annotated steps:**
```java
import io.qameta.allure.Step;
import org.junit.jupiter.api.Test;

class TestMyWebsite {

    @Test
    void testAuthentication() {
        step1();
        step2();
    }

    @Step("Step 1")
    void step1() {
        subStep1();
        subStep2();
    }

    @Step("Sub-step 1")
    void subStep1() {
        // ...
    }

    @Step("Sub-step 2")
    void subStep2() {
        // ...
    }

    @Step("Step 2")
    void step2() {
        // ...
    }
}
```

**Lambda steps and no-op steps:**
```java
import io.qameta.allure.Allure;
import org.junit.jupiter.api.Test;

class TestMyWebsite {

    @Test
    void testAuthentication() {

        Allure.step("Step 1", step -> {

            // ...
            Allure.step("Sub-step 1");

            // ...
            Allure.step("Sub-step 2");
        });

        Allure.step("Step 2", step -> {
            // ...
        });
    }
}
```

### Describe parametrized tests

When using the [parametrized tests](/docs/v2/readability/#parametrized-tests) pattern, use Allure JUnit Jupiter's `@Param` or `parameter()` to add the parameters to the report, see the [reference](/docs/junit-jupiter-reference/#parametrized-tests).

**Annotations API:**
```java
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

class TestMyWebsite {

    @ParameterizedTest(name = "{displayName} ({argumentsWithNames})")
    @ValueSource(strings = {"johndoe", "johndoe@example.com"})
    void testAuthentication(String login) {
        // ...
    }
}
```

**Runtime API:**
```java
import io.qameta.allure.Allure;
import org.junit.jupiter.api.Test;

class TestMyWebsite {

    @Test
    void testAuthenticationWithUsername() {
        Allure.parameter("login", "johndoe");
        // ...
    }

    @Test
    void testAuthenticationWithEmail() {
        Allure.parameter("login", "johndoe@example.com");
        // ...
    }
}
```

Tip:
Allure reads the arguments of `@ParameterizedTest` methods through a JUnit extension that is registered automatically. For it to be loaded, enable extension autodetection in `src/test/resources/junit-platform.properties`:

```properties
junit.jupiter.extensions.autodetection.enabled=true
```

Without this property, the arguments are still visible in the test name, but they are not reported as parameters.

### Attach screenshots and other files

You can [attach any sorts of files](/docs/attachments/) to your Allure report. For example, a popular way to make a report easier to understand is to attach a screenshot of the user interface at a certain point.

Allure JUnit Jupiter provides various ways to create an attachment, both from existing files or generated dynamically, see the [reference](/docs/junit-jupiter-reference/#attachments).

```java
import io.qameta.allure.Allure;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;

class TestMyWebsite {

    @Test
    void testAuthentication() throws IOException {
        // ...
        Allure.attachment("data.txt", "This is the file content.");
        try (InputStream is = Files.newInputStream(Paths.get("/path/img.png"))) {
            Allure.attachment("image.png", is);
        }
    }
}
```

Tip:

Consult our guides for integrating screenshots in JUnit 5 with Allure Report:

- [Integrating screenshots in JUnit 5 and Selenide](/docs/guides/junit5-selenide-screenshots/)
- [Integrating screenshots in JUnit 5 and Selenium](/docs/guides/junit5-selenium-screenshots/)

### Select tests via a test plan file

If the `ALLURE_TESTPLAN_PATH` environment variable is defined and points to an existing file, JUnit will only run tests listed in this file.

Here's an example of running tests according to a file named `testplan.json`:

**MacOS/Linux:**
```bash
export ALLURE_TESTPLAN_PATH=testplan.json
./gradlew test
```

**Windows:**
```powershell
$Env:ALLURE_TESTPLAN_PATH = "testplan.json"
gradlew test
```

### Environment information

For the main page of the report, you can collect various information about the environment in which the tests were executed.

For example, it is a good idea to use this to remember the OS and Java versions. This may help the future reader investigate bugs that are reproducible only in some environments.

Images: /images/java/environment-allure3-light.png, /images/java/environment-allure3-dark.png, /images/java/environment-allure2-light.png, /images/java/environment-allure2-dark.png

To provide environment information, put a file named `environment.properties` into the `allure-results` directory after running the tests. See the example in [Environment file](/docs/how-it-works-environment-file/).

Note that this feature should be used for properties that do not change for all tests in the report. If you have properties that can be different for different tests, consider using [Parametrized tests](/docs/junit-jupiter-reference/#parametrized-tests).
