/
Maven plugin

Maven plugin

Using the releases version

There is no need for any Maven setup to use the releases of the GreenPepper Maven plugin. The binaries are already uploaded to Central 

Use the development version of the GreenPepper Maven plugin

 You will need to set your Maven up to access OSS repository

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <profiles>
        <profile>
            <id>ossrh</id>
            <repositories>
                <repository>
                    <id>ossrh</id>
                    <name>Sonatype Public Repository</name>
                    <url>https://oss.sonatype.org/content/groups/public/</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>ossrh</id>
                    <name>Sonatype Public Repository</name>
                    <url>https://oss.sonatype.org/content/groups/public/</url>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>ossrh</activeProfile>
    </activeProfiles>
</settings>

Configure GreenPepper Maven plugin

The GreenPepper Maven plugin is used during the Preintegration test phase of the build lifecycle to compile and copy the fixtures classes of an application. By default, it copies the classes to:

${project.build.directory}/fixture-test-classes/ 


The GreenPepper Maven plugin is then used during the Integration test phase of the build lifecycle to execute the specifications of an application. It generates reports in plain HTML file format (*.html). By default, these files are generated in:

$basedir/target/greenpepper-reports/


The GreenPepper Maven plugin is used during the Postintegration test phase of the build lifecycle to create the fixtures jar of an application. By default, it generates a jar in:

$basedir/target/
<plugin>
    <groupId>com.github.strator-dev.greenpepper</groupId>
    <artifactId>greenpepper-maven-plugin</artifactId>
    <version>4.0</version>
	<configuration>
	    <source>1.6</source>
	    <target>1.6</target>
        <fixtureGenerator implementation="com.greenpepper.maven.plugin.spy.impl.JavaFixtureGenerator">
            <defaultPackage><!-- the package where to generate the fixture per default --></defaultPackage>
        </fixtureGenerator>
	    <fixtureSourceDirectory><!-- put your fixture sources directory --></fixtureSourceDirectory>
	    <fixtureOutputDirectory><!-- put your fixture classes directory --></fixtureOutputDirectory>
	    <specsDirectory><!-- destination for downloaded specification files --></specsDirectory>
        <selectedRepository><!-- [since 4.0] The name of the repository you want to use --></selectedRepository>
	    <resources>
	        <resource>
	            <directory></directory>
	            <excludes>
	                <exclude>**/*.java</exclude>
	            </excludes>
	        </resource>
	    </resources>
	    <repositories>
	        <repository>
		        <type><!-- put your suite resolver class--></type>
		        <suites>
		        	<suite><!-- put your suite uri --></suite>
		        </suites>
	        </repository>
	        <repository>
	            <type><!-- put your test resolver class--></type>
	            <tests>
	            	<test><!-- put your test uri --></test>
	            </tests>
	        </repository>
	    </repositories>
	</configuration>
<plugin>

Use GreenPepper Maven plugin

Executing specification fixtures

Except for the Freeze goal, the goals for the GreenPepper Maven plugin are bound to their respective phases in the build lifecycle. So, to compile your fixture sources, you only need to indicate Maven until which lifecycle to execute.

Providing you have configured your plugin (see section below):

  • The following will compile your fixture sources: 

    mvn greenpepper:compile
  • The following will copy your resources: 

    mvn greenpepper:resources
  • The following will execute your specifications: 

    mvn greenpepper:run
  • The following will create you fixture jar: 

    mvn greenpepper:fixture-jar
  • The following will download the specification files: 

    mvn greenpepper:freeze
  • The following will generate the fixture

    mvn greenpepper:generate-fixtures

Testing a Single Specification

 

Reminder

Keep in mind the following :

  • -Dgp.repo=<Repository name> : Specify the repository to target
  • -Dgp.test=<Specification name> : Specify the specification to test

 

 

You can use the command line to launch a test on a single specification. This requires a setup though. You need to  setup your project with : 

  • A list of repositories 
  • (Optional) One of the repositories set as default

Managing a single repository

Here is a configuration with a single repository.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>dummy</groupId>
    <artifactId>dummy</artifactId>
    <version>${project.version}</version>
	<name>test greenpepper runner</name>

	<build>
		<plugins>
            <plugin>
                <groupId>com.github.strator-dev.greenpepper</groupId>
				<artifactId>greenpepper-maven-plugin</artifactId>
				<version>${project.version}</version>
				<configuration>
					<locale>en</locale>
					<debug>true</debug>
					<fixtureOutputDirectory>target/test-classes</fixtureOutputDirectory>
					<reportsDirectory>target/greenpepper-reports</reportsDirectory>
					<systemUnderDevelopment>com.greenpepper.systemunderdevelopment.DefaultSystemUnderDevelopment</systemUnderDevelopment>

					<!-- Sample repositories configuration -->

					<repositories>
						<repository>
							<type>com.greenpepper.repository.FileSystemRepository</type>
							<root>src/test/resources/com/greenpepper/maven/plugin</root>
							<name>file</name>
							<isDefault>true</isDefault>
							<tests>
								<test>wrong.html</test>
							</tests>
						</repository>
						<repository>
							<type>com.greenpepper.runner.repository.AtlassianRepository</type>
							<root><![CDATA[http://domain:port/rpc/xmlrpc?handler=handler&includeStyle=true#SPACE KEY]]></root>
							<name>confluence</name>
							<tests>
								<test>PAGE TITLE</test>
							</tests>
						</repository>
					</repositories>
				</configuration>
			</plugin>
		</plugins>
	</build>

</project> 

Suppose that there is a set of files in the repository folder including one named right.html. You can test this Specification with the following command.

mvn greenpepper:run -Dgp.test=right.html

Managing multiple repositories

Here is a configuration that contains 2 repositories. You will notice that one of them is marked as default.

<repository>
    ......
	<name>file</name>
	<isDefault>true</isDefault>
	......
</repository>

This will be the repository used when launching a single page per default. There is a way to choose the other one. You will need to use the name of the repository as a parameter.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>dummy</groupId>
    <artifactId>dummy</artifactId>
    <version>4.0</version>
	<name>test greenpepper runner</name>
	<build>
		<plugins>
            <plugin>
                <groupId>com.github.strator-dev.greenpepper</groupId>
				<artifactId>greenpepper-maven-plugin</artifactId>
				<version>4.0</version>
				<configuration>
					<locale>en</locale>
					<debug>true</debug>
					<fixtureOutputDirectory>target/test-classes</fixtureOutputDirectory>
					<reportsDirectory>target/greenpepper-reports</reportsDirectory>
					<systemUnderDevelopment>com.greenpepper.systemunderdevelopment.DefaultSystemUnderDevelopment</systemUnderDevelopment>

					<!-- Sample repositories configuration -->

					<repositories>
						<repository>
							<type>com.greenpepper.repository.FileSystemRepository</type>
							<root>src/test/resources/com/greenpepper/maven/plugin</root>
							<name>file</name>
							<isDefault>true</isDefault>
							<tests>
								<test>wrong.html</test>
							</tests>
						</repository>
						<repository>
							<type>com.greenpepper.runner.repository.AtlassianRepository</type>
							<root><![CDATA[http://domain:port/rpc/xmlrpc?handler=handler&includeStyle=true#SPACE KEY]]></root>
							<name>confluence</name>
							<tests>
								<test>PAGE TITLE</test>
							</tests>
						</repository>
					</repositories>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

Calling the command line

With default repository

Supposing there is a right.html file in src/test/resources/com/greenpepper/maven/plugin

mvn greenpepper:run -Dgp.test=right.html

The same command will work if you have defined a single repository (even when it's not set as default)

With the non default repository

Supposing there is a "My Other PAGE TITLE" file on the confluence server .

mvn greenpepper:run -Dgp.test="My Other PAGE TITLE" -Dgp.repo=confluence