apache / apache/maven-surefire

[SUREFIRE-1720] JUnit 5 @Nested classes are not excluded when name ends in Tests

Open
#2,010 1 comment 0 reactions 0 assignees View on GitHub
bug priority:minor
Dominant language
Java
Stars
461
Forks
588
Avg merge
1d 8h
Merged PRs (30d)
19

Description

**[Dmitry Timofeev](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=dt)** opened **[SUREFIRE-1720](https://issues.apache.org/jira/browse/SUREFIRE-1720?redirect=false)** and commented

`` over source file names does not exclude the `@Nested` test classes, defined inside the matching source files, if they end with `Tests`.

### Minimal reproducing project

https://github.com/dmitry-timofeev/surefire-bug (contains the instrutctions to run)

See AppIntegrationTest.

### Surefire Configuration

```java

maven-surefire-plugin
${surefire.version}



**/*IntegrationTest.java


```

### Expected Behaviour

When a pattern over source file names is used (`*Pattern.java`),
it must apply to all classes inside that file (including `@Nested` with any name).

### Actual Behaviour

The exclusion does not apply to some `@Nested` classes inside the matching source file (e.g, ending with `Tests`).

### Workaround

Also add a pattern, operating on _classes:_ `%regex[.*IntegrationTest\$.*]`

---

**Affects:** 2.22.2, 3.0.0-M3

Contributor guide

Open the contributing guide

Research direction

Start with the linked minimal reproducing project and its documented instructions, then inspect AppIntegrationTest and the Surefire exclusion behavior described in the configuration. Confirm that a source-file exclusion also excludes every nested class, including names ending in Tests, and verify that the class-regex workaround is no longer needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.