Skip to content

Surefire plugin includes all .java files as tests (potential misconfiguration) #1561

Description

@Abhishek2003ij

Hey,

I was going through the build setup and noticed this in the surefire plugin:

**/*.java

From what I understand, this would make Maven try to run all Java files as tests, not just the usual *Test.java ones.

I might be missing some context here, but I was wondering if this could lead to a few issues:

non-test classes being picked up and executed as tests
longer build times since everything under src might be scanned
possible runtime errors if classes without test annotations get picked up

Also noticed there’s an excludesFile configured alongside this — just curious how these two interact, since overriding the default includes might change the expected behavior there.

Another small thing I came across while looking through the config:
the Spotless plugin is using:

*.java

which seems like it would only match Java files in the root directory and not in nested folders like src/main/java. Not sure if that’s intentional or if it was meant to be recursive (**/*.java).

Just wanted to double-check if these are intentional choices or if there’s room to tighten them up a bit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions