Class IntegrationTestMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.archetype.mojos.IntegrationTestMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="integration-test", requiresProject=true) public class IntegrationTestMojo extends org.apache.maven.plugin.AbstractMojo

Execute the archetype integration tests, consisting in generating projects from the current archetype and optionally comparing generated projects with reference copy.

Each IT consists of a sub-directory in src/test/resources/projects containing:

  • a goal.txt file, containing a list of goals to run against the generated project (can be empty, content ignored before maven-archetype-plugin 2.1),
  • an archetype.properties file, containing properties for project generation,
  • an optional reference/ directory containing a reference copy of the expected project created from the IT.

To let the IT create a Maven module below some other Maven project (being generated from another archetype) one can additionally specify an optional archetype.pom.properties file in the parent directory, specifying the archetype's groupId, artifactId and version along with its archetype.properties file, containing properties for project generation. Both files are leveraged to create the parent project for this IT. Parent projects can be nested.

An example structure for such an integration test looks like this

integration test folder structure
File/Directory Description
src/test/resources/projects/it1 Directory for integration test 1
src/test/resources/projects/it1/archetype.pom.properties GAV for the archetype from which to generate the parent
src/test/resources/projects/it1/archetype.properties All required properties for the archetype being specified by archetype.pom.properties on this level
src/test/resources/projects/it1/child Directory for maven module within integration test 1 (this folder's name is not relevant)
src/test/resources/projects/it1/child/goal.txt The file containing the list of goals to be executed against the generated project
src/test/resources/projects/it1/child/archetype.properties All required properties for this project's archetype

Notice that it is expected to be run as part as of a build after the package phase and not directly as a goal from CLI.

Author:
rafale
  • Constructor Details

  • Method Details

    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • buildInterpolatedFile

      protected void buildInterpolatedFile(File originalFile, File interpolatedFile) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException