Terratest Maven plugin

Plugin for running and compiling terratest (or any go) tests

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.github.terratest-maven-plugin
ArtifactId

ArtifactId

terratest-maven-plugin
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Terratest Maven plugin
Plugin for running and compiling terratest (or any go) tests
Project URL

Project URL

https://github.com/terratest-maven-plugin
Project Organization

Project Organization

terratest-maven-plugin
Source Code Management

Source Code Management

https://github.com/terratest-maven-plugin/terratest-maven-plugin

Download terratest-maven-plugin

How to add to project

<plugin>
    <groupId>com.github.terratest-maven-plugin</groupId>
    <artifactId>terratest-maven-plugin</artifactId>
    <version>1.0.1</version>
</plugin>

Dependencies

compile (17)

Group / Artifact Type Version
org.apache.maven : maven-core jar 3.2.5
org.apache.maven : maven-compat jar 3.2.5
org.apache.maven : maven-model jar 3.2.5
org.apache.maven : maven-plugin-api jar 3.2.5
org.apache.maven : maven-aether-provider jar 3.2.5
org.codehaus.plexus : plexus-utils jar 3.0.15
org.apache.maven.shared : maven-verifier jar 1.7.2
org.apache.maven : maven-project jar 2.2.1
org.apache.commons : commons-lang3 jar 3.12.0
org.slf4j : slf4j-log4j12 jar 1.7.30
com.github.spullara.mustache.java : compiler jar 0.8.18
com.fasterxml.jackson.core : jackson-core jar 2.12.2
com.fasterxml.jackson.core : jackson-annotations jar 2.12.2
com.fasterxml.jackson.core : jackson-databind jar 2.12.2
com.fasterxml.jackson.datatype : jackson-datatype-jsr310 jar 2.12.2
com.google.guava : guava jar 30.1-jre
org.apache.commons : commons-collections4 jar 4.4

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations Optional jar 3.6.0

test (2)

Group / Artifact Type Version
org.apache.maven.plugin-testing : maven-plugin-testing-harness jar 3.3.0
junit : junit jar 4.13.2

Project Modules

There are no modules declared in this project.

terratest-maven-plugin

This is a Maven plugin for running Terratests or any go test in your repository. Terratest is used to create infrastructure tests with popular language go. With this plugin you can run these tests, create HTML reports out of the box with your beloved maven build pipeline. You can use this plugin to run all your go tests, it has no explicit dependency on terratest.

CircleCI License: MIT Maven Central

Usage

Include in your pom.xml

<build>
    ...
        <plugins>
            ...
            <plugin>
                <groupId>com.github.terratest-maven-plugin</groupId>
                <artifactId>terratest-maven-plugin</artifactId>
                <version>1.0.1</version>
                <configuration>
                    <terraTestPath>{[ABSOLUTE-PATH-TO-TERRATESTS]}</terraTestPath>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>run-tests</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            ...
        </plugins>
        ...
</build>

Goals

Goal Description Default Lifecycle Phase
terratest:compile Compile Terratests inside the terratestPath directory compile
terratest:run-tests Run go tests inside terratestPath test

Required parameters

<configuration>
   <terraTestPath>{[ABSOLUTE-PATH-TO-TERRATESTS]}</terraTestPath>
</configuration>

Sets the working directory for the goal compile or run-tests

Example

For examples, check out: Terratest maven plugin examples repository.

Optional parameters

Generating logs

You can generate log files into your terraTestPath directory from the stdOut and stdErr of the go test results. Use the following parameter:

<configuration>
    ...
    <createLogFile>true</createLogFile>
    ...
</configuration>

This will generate an terratest-output.log and an terratest-error-output.log inside your terraTestPath

Generating HTML report

Only used in run-tests goal
You can have an HTML report about your test results into your terraTestPath directory as index.html.

HTML report example
Use the following parameter:

<configuration>
...
 <generateHtmlReport>true</generateHtmlReport>
...
</configuration>

Use json output

You can set the useJsonOutput parameter so go test results will be logged as json. This combined with createLogFile parameter eases further processing.

<configuration>
...
 <useJsonOutput>true</useJsonOutput>
...
</configuration>

Example output:

{"Time":"2021-03-24T09:06:19.39012+01:00","Action":"run","Package":"io/jinfra/terratest/maven/plugin/tests/m/v2","Test":"TestValidDockerTestMavenProject"}
{"Time":"2021-03-24T09:06:19.390426+01:00","Action":"output","Package":"io/jinfra/terratest/maven/plugin/tests/m/v2","Test":"TestValidDockerTestMavenProject","Output":"=== RUN   TestValidDockerTestMavenProject\n"}

Skip tests

Only used in run-tests goal
terratest-maven-plugin integrates with the widely used -DskipTests, so if you run this for example:

mvn clean install -DskipTests

your terratests won't run. Of course, you can set it directly in the plugin/pluginManagement section:

<configuration>
...
<skipTests>true</skipTests>
...
</configuration>

The effect will be the same. If you want to compile your go tests even if tests are disabled use the terratest:compile goal, for example like this:

<plugin>
    <groupId>com.github.terratest-maven-plugin</groupId>
    <artifactId>terratest-maven-plugin</artifactId>
    <configuration>
        <terraTestPath>${project.basedir}/docker-test</terraTestPath>
        </configuration>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>
            </goals>
        </execution>
    </executions>
</plugin>

This will bound to compile lifecycle by default. If you want to change this behaviour, use the phase parameter in execution.

Disable test caching

Only used in run-tests goal
Go can use a mechanics called test caching. This is enabled by default, but you can switch it off by using the following parameter:

<configuration>
...
<skipTests>true</skipTests>
...
</configuration>

Add further arguments

You can include further arguments with the go test or compiling. use the following parameter:

<configuration>
...
    <arguments>
        <param>arg1</param>
        <param>arg1</param>
    </arguments>
...
</configuration>

For full reference of the arguments you can use with go test, see the Go test reference

Contribution

If you'd like to contribute, please feel free. This is an MIT licenced application, so you can use it, extends it however you want. :)

Build the project

Clone this project. Use maven 3.0.0 or newer for building. Once you done with your changes and sufficient amount of tests have been done, create a pull request.

com.github.terratest-maven-plugin

Terratest Maven Plugin

Maven plugin for Terratest

Versions

Version
1.0.1
1.0.0