Skip to content

@MavenProjectSources - if no parameters set, then use "maven_project" subdirectory? #378

Open
@hugoheden

Description

@hugoheden

The @MavenProjectSources (new since 0.12) is very useful. If the user does not set any parameters to it (neither resourcesUsage nor sources), I have a vague suggestion what it should default to.

The has similar semantics to @MavenProject, which - when used without paramenters - defaults to a directory called maven_project. So I am just wondering if @MavenProjectSources should behave similarly - i.e default to using the maven_project subdirectory?

Argumentation:

In the current documentation for @MavenProject, we see this example:

@MavenJupiterExtension
class SetIT
{
    private static final String VERSIONS_PLUGIN_SET =
      "${project.groupId}:${project.artifactId}:${project.version}:set";

    @Nested
    @MavenProject
    @TestMethodOrder( OrderAnnotation.class )
    @MavenOption(MavenCLIOptions.NON_RECURSIVE)
    @MavenGoal(VERSIONS_PLUGIN_SET)
    class set_001
    {

        @SystemProperty(value = "newVersion", content="2.0")
        @MavenTest
        @Order(10)
        void first( MavenExecutionResult result )
        {
            assertThat( result ).isSuccessful();
        }

        @SystemProperty(value = "newVersion", content="2.0")
        @SystemProperty(value = "groupId", content="*")
        @SystemProperty(value = "artifactId", content="*")
        @SystemProperty(value = "oldVersion", content="*")
        @MavenTest
        @Order(20)
        void second( MavenExecutionResult result)
        {
            assertThat( result ).isSuccessful();
        }
    }
}

And then we learn that we should place the project in a directory named maven_project:

The @MavenProject defines that project name which is by default maven_project. This means, 
you have to define the project you would like to test on like this: ....

Ok, so I am just thinking that it would be elegantly consistent that the @MavenProjectSources would behave similarly - it could default to using the maven_project subdirectory.

There could be a section in the documentation right before (or after) the above section, that would contain a similar code example as above, but using @MavenProjectSources (without parameters) instead of @MavenProject (and without any ordering of the tests):

@MavenJupiterExtension
class SetIT
{
    private static final String VERSIONS_PLUGIN_SET =
      "${project.groupId}:${project.artifactId}:${project.version}:set";

    @Nested
    @MavenProjectSources
    @MavenOption(MavenCLIOptions.NON_RECURSIVE)
    @MavenGoal(VERSIONS_PLUGIN_SET)
    class set_001
    {

        @SystemProperty(value = "newVersion", content="2.0")
        @MavenTest
        void some_test( MavenExecutionResult result )
        {
            assertThat( result ).isSuccessful();
        }

        @SystemProperty(value = "newVersion", content="3.0")
        @MavenTest
        void some_other_test( MavenExecutionResult result)
        {
            assertThat( result ).isSuccessful();
        }
    }
}

I think this usage of @MavenProjectSources could be documented in the same section as the @MavenProject, because it would highlight the similarities and differences between the two annotations nicely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions