Skip to content

Maven Surefire Plugin does not execute static nested classes #1377

@rweisleder

Description

@rweisleder

Overview

As suggested by @sbrannen and maybe related to #1343.

Discussion on SO: https://stackoverflow.com/a/47982480/4365460

Consider this class:

import org.junit.jupiter.api.Test;

class OuterTest {

    @Test
    void method() {
        System.out.println("OuterTest.method()");
    }

    static class InnerTest {

        @Test
        void method() {
            System.out.println("InnerTest.method()");
        }
    }
}

The tests in InnerTest are picked up by Gradle (junit-platform-gradle-plugin) and IntelliJ IDEA, but not with the Maven Surefire Plugin.

pom.xml:

<properties>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <junit-platform.version>1.1.0</junit-platform.version>
    <junit-jupiter.version>5.1.0</junit-jupiter.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>${junit-jupiter.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <dependencies>
                <dependency>
                    <groupId>org.junit.platform</groupId>
                    <artifactId>junit-platform-surefire-provider</artifactId>
                    <version>${junit-platform.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.junit.jupiter</groupId>
                    <artifactId>junit-jupiter-engine</artifactId>
                    <version>${junit-jupiter.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

The issue is reproducible with 5.0.0, 5.1.0 and 5.2.0-M1 (and related version of JUnit Platform).

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions