Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

 

Installing the GreenPepper Maven Plugin

 

In order to install the GreenPepper Image Added Maven Plugin, it is necessary to add a plugin entry to your project's pom.xml.

Code Block
languagexml
<plugin>
	<groupId>com.greenpepper</groupId>
	<artifactId>greenpepper-maven-plugin</artifactId>
	<version>4.0.0-SNAPSHOT</version>
	...
	<!-- further configuration here -->
</plugin>

...

For automatic downloads and upgrades, it is possible to add additional repositories to your project's pom.xml like this:

Code Block
languagexml
<repositories>
	<repository>
		<id>novatec</id>
		<url>http://nexus.novatec-gmbh.lan/content/groups/public</url>
		<snapshots>
			<enabled>true</enabled>
			<updatePolicy>never</updatePolicy>
		</snapshots>
		<releases>
			<enabled>true</enabled>
			<updatePolicy>never</updatePolicy>
		</releases>
</repositories>
 
<pluginRepositories>
	<id>novatec</id>
	<url>http://nexus.novatec-gmbh.lan/content/groups/public</url>
	<snapshots>
		<enabled>true</enabled>
		<updatePolicy>never</updatePolicy>
	</snapshots>
	<releases>
		<enabled>true</enabled>
		<updatePolicy>never</updatePolicy>
	</releases>
</pluginRepositories>

 

...

Configuring the GreenPepper Maven Plugin

 

Considering Within the default Maven Build Lifecycle, there are three phases in which using the GreenPepper Image Added Maven Plugin is used.
 

  • During the Pre-Integration Test, the plugin is used to compile and copy the fixture classes of an application. By default, the compiled classes are copied to:
    ${project.build.directory}/fixture-test-classes/

...

In step one ("Installing the GreenPepper Image Added Maven Plugin") we had a look on a short block of code where it said "further configuration here". Below you find an example of how said configuration could look like.

Code Block
languagexml
<plugin>
	<groupId>com.greenpepper</groupId>
	<artifactId>greenpepper-maven-plugin</artifactId>
	<version><!-- your version of the GreenPepper Maven Plugin --></version>
	<configuration>
	    <source><!-- your source version --></source>
	    <target><!-- your target version --></target>
	    <fixtureSourceDirectory><!-- source directory of your fixtures, for example: src/fixture/java --></fixtureSourceDirectory>
	    <fixtureOutputDirectory><!-- output directory of the compiled fixture classes, for example: target/fixture-test-classes --></fixtureOutputDirectory>
	    <specsDirectory><!-- destination for downloaded specification files, for example: src/sprecs--></specsDirectory>
		<reportsDirectory><!-- destination for generated HTML reports, for example: target/greenpepper-reports</reportsDirectory>
		<reportsType><!-- the file format of your reports (XML or HTML, default is HTML) --></reportsType>
	    <resources>
	        <resource>
	            <directory><! -- directory for a specific resource. Example: src/fixture/resources--></directory>
	            <excludes>
	                <exclude>**/*.java</exclude>
	            </excludes>
	        </resource>
	    </resources>
	    <repositories>
	        <repository>
		        <type><!-- fully qualified name of your suit resolver class, for instance: com.greenpepper.repository.FileSystemRepository --></type>
				<root><!-- root directory of the current repository. Example: ${basedir}/src/fixture/specs --></root>
		        <suites>
		        	<suite><!-- the suit's URI --></suite>
		        </suites>
	        </repository>
	        <repository>
	            <type><!-- fully qualified name of your test resolver. --></type>
	            <tests>
	            	<test><!-- the test's URI --></test>
	            </tests>
	        </repository>
	    </repositories>
		<goalPrefix><!-- the prefix that will be associated with the plugin (optional, see below "Using the GreenPepper Maven Plugin"), eg: greenpepper --></goalPrefix>
	</configuration>
</plugin>

...

Using the GreenPepper Maven Plugin

...

Executing specification fixtures

Generally, the goals of the GreenPepper Image Added Maven Plugin correspond to the phases of the default Maven Build Lifecycle (with exception of the Freeze goal). Therefore, in order to interact with our fixture sources, we only have to tell Maven until which goal it should run.
NOTE: In order to use a prefix as we do below, it might be necessary to define the goalPrefix tag within the plugin configuration (see the code box above).
 

  • Compile fixture sources

    Code Block
    mvn greenpepper:compile
  • Copy resources to the destination directory

    Code Block
    mvn greenpepper:resources
  • Execute specifications

    Code Block
    mvn greenpepper:run
  • Create fixture jars

    Code Block
    mvn greenpepper:fixture-jar
  • Download specification files

    Code Block
    mvn greenpepper:freeze

Goals

 

Now that we know which goals exist for the GreenPepper Image Added Maven Plugin, let's have a closer look at each of them.

...

  • resources: List of resources to be copied to the output directory.

    • Type: java.util.List
    • Expression: none
       
  • fixtureOutputDirectory: Output directory the resources are copied to.

    • Type: java.io.File
    • Expression: ${project.build.directory}/fixture-test-classes

greenpepper:run 


Executes GreenPepper Image Added specifications.

Mojo attributes:

...

  • fixtureOutputDirectory: Directory containing the compiled fixture classes.

    • Type: java.io.File
    • Expression: ${project.build.directory}/fixture-test-classes

...

greenpepper:freeze


Downloads specification files from a remote repository and stores them locally.

...

Note that the values of the expressions given below are merely default values, so therefore their use is not mandatory. 
 

  • specsDirectory: Destination directory for specifications to be downloaded. Specifications are stored in a subdirectory named after the given repository and optionally in a subdirectory named after the suite.

    • Type: java.io.File
    • Expression: ${basedir}/src/specs

 

...

Examples
 

GreenPepper Core pom.xml

...

  •  Add the reportsType tag to the plugin configuration in your project's pom.xml

    Code Block
    <reportsType>xml</reportsType>
  • Add a reports type specification to the command line

    Code Block
    -Dmaven.greenpepper.reports.type=xml

 

Maven Runner

 

Configuring a System Under Test can be exhausting if you have a lot of library dependencies. In order to make the configuration process a little easier, the Maven Runner uses your existing pom.xml to automatically
resolve dependencies needed for the execution of specifications, whereby only the dependencies tag is read. Artifacts found will be resolved and added to the classpath of the runner. The project's artifact itself will
also be added to the classpath. 

Further information on the Maven Runner can be found here.

 

 

 

 

 

 

 

 

 

 

 

...