Skip to content

TestsShouldNotBePublic should also pick up meta annotations #308

Description

@timtebeek

TestsShouldNotBePublic should also remove public modifier from classes containing methods meta-annotated with @Test and other such annotations. Seen on openrewrite/rewrite-maven-plugin#498, where the initial commit did not pick up on the @MavenTest annotations in our tests, which are themselves annotated with @Test.

@MavenJupiterExtension
@MavenOption(MavenCLIOptions.NO_TRANSFER_PROGRESS)
@MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:discover")
-public class DiscoverNoActiveRecipeIT {
+class DiscoverNoActiveRecipeIT {

    @MavenTest // <!-- because `@MavenTest` is annoted with `@Test`
    void single_project(MavenExecutionResult result) {
        assertThat(result)
                .isSuccessful()
                .out()
                .error()
                .noneSatisfy(line -> assertThat(line).contains("Could not find recipe 'null' among available recipes"));
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions