Annotation Interface Basedir


@Target({TYPE,METHOD}) @Retention(RUNTIME) @Inherited public @interface Basedir
Specifies the base directory for test resources in Maven plugin tests. This annotation can be applied to test classes or methods to define where test resources (such as POM files, source files, and other test artifacts) are located.

If not specified, the plugin's base directory will be used as the default.

Example usage on class level:

 
 @MojoTest
 @Basedir("src/test/resources/my-test-project")
 class MyMojoTest {
     @Test
     @InjectMojo(goal = "compile")
     void testCompilation(MyMojo mojo) {
         // Test resources will be loaded from src/test/resources/my-test-project
         mojo.execute();
     }
 }
 
 

Example usage on method level:

 
 @MojoTest
 class MyMojoTest {
     @Test
     @Basedir("src/test/resources/specific-test-case")
     @InjectMojo(goal = "compile")
     void testSpecificCase(MyMojo mojo) {
         // Test resources will be loaded from src/test/resources/specific-test-case
         mojo.execute();
     }
 }
 
 

When applied at both class and method level, the method-level annotation takes precedence.

Since:
4.0.0
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The path to the base directory for test resources.
  • Element Details

    • value

      String value
      The path to the base directory for test resources. The path can be absolute or relative to the test class location.
      Returns:
      the base directory path, or an empty string to use the default
      Default:
      ""