Dashboard > GreenPepper Open Documentation Refactoring > ... > Maven 2 plugin > 3. Use GreenPepper Maven plugin
  GreenPepper Open Documentation Refactoring Log In View a printable version of the current page.  
  3. Use GreenPepper Maven plugin
Added by Laurent Cobos, last edited by Francois Denommee on Jun 16, 2010  (view change)
Labels: 
(None)

3. 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

Goals

greenpepper:compile

It compiles fixtures of an application.

Mojo attributes:

  • Requires a Maven 2.0 project to execute
  • Requires dependency resolution of artifacts in scope: test
  • Automatically executes within the lifecycle phase: preintegration test

Required parameters

Name Type Description
fixtureSourceDirectory File The source directory containing the fixture sources to be compiled.
fixtureOutputDirectory File The output directory into which to copy the resources.

Optional parameters

Same as Maven compiler plugin.

Parameter details

fixtureSourceDirectory: The source directory containing the fixture sources to be compiled.

  • Type: java.io.File
  • Required: Yes
  • Expression:


fixtureOutputDirectory: The output directory into which to copy the resources.

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

greenpepper:resources

It copies resources for the main source code to the main output directory.

Mojo attributes:

  • Requires a Maven 2.0 project to execute
  • Automatically executes within the lifecycle phase: preintegration test

Required parameters

Name Type Description
fixtureOutputDirectory File The output directory into which to copy the resources.
resources List The list of resources to be transfered.

Optional parameters

Same as Maven 2 resources plugin

Parameter details

fixtureOutputDirectory: The output directory into which to copy the resources.

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


Resources: The list of resources we want to transfer.

  • Type: java.util.List
  • Required: Yes
  • Expression:

greenpepper:run

It executes the GreenPepper specifications.

Mojo attributes:

  • Requires a Maven 2.0 project to execute
  • Requires dependency resolution of artifacts in scope: test
  • Automatically executes within the lifecycle phase: integration test

Required parameters

Name Type Description
basedir File The base directory of the project being tested. This can be obtained in your unit test by System.getProperty("basedir").
classesDirectory File The directory containing generated classes of the project being tested.
fixtureOutputDirectory File The directory containing generated fixture classes of the project being tested.
repositories Repository Suite or test uri of specifications to test.
reportsDirectory File Output directory of the generated reports.
stopOnFirstFailure Boolean Stop the execution of the specification on the first failure
testFailureIgnore Boolean Set this to true to ignore a failure during testing. Its use is NOT RECOMMENDED, but quite convenient on occasion.

Parameter details

basedir: The base directory of the project being tested. This can be obtained in your unit test by System.getProperty("basedir").

  • Type: java.io.File
  • Required: Yes
  • Expression: ${basedir}


classesDirectory: The directory containing generated classes of the project being tested.

  • Type: java.util.List
  • Required: Yes
  • Expression: ${project.build.outputDirectory}


fixtureOutputDirectory: The output directory into which to copy the resources.

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


reportsDirectory: Output directory of the generated reports.

  • Type: java.io.File
  • Required: yes
  • Expression: ${project.build.directory}/greenpepper-reports

greenpepper:fixture-jar

It builds the fixture jar.

Mojo attributes:

  • Requires a Maven 2.0 project to execute
  • Requires dependency resolution of artifacts in scope: test
  • Automatically executes within the lifecycle phase: postintegration test

Required parameters

Name Type Description
fixtureOutputDirectory File The directory containing generated fixture classes of the project being tested.

Parameter details

fixtureOutputDirectory: The output directory into which to copy the resources.

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

greenpepper:freeze

It downloads specification files from the remote repositories and stores them locally.

Have a look at this blog post : Put your specifications in the freezer

Mojo attributes:

  • Requires a Maven 2.0 project to execute
  • Requires dependency resolution of artifacts in scope: test
  • Is not bound to any lifecycle phase

Required parameters

Name Type Description
specsDirectory File The directory where specification files should be downloaded. Default value: ${basedir}/src/specs
repositories Repository Suite or test uri of specifications to download.

Parameter details

specsDirectory: The destination directory for specifications. Specification files will be stored under a sub-directory named after the repository and optionally a sub-directory named after the suite.

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

Examples

GreenPepper Core Pom.xml example

 <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>

    <artifactId>greenpepper-core</artifactId>
    <packaging>jar</packaging>
    <name>GreenPepper Core</name>

    <parent>
        <groupId>greenpepper-open</groupId>
        <artifactId>greenpepper-open</artifactId>
        <version>2.6</version>
    </parent>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>greenpepper</groupId>
                <artifactId>greenpepper-maven-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                    <fixtureSourceDirectory>src/fixture/java</fixtureSourceDirectory>
                    <fixtureOutputDirectory>target/fixture-test-classes</fixtureOutputDirectory>
                    <specsDirectory>src/specs</specsDirectory>
                    <reportsDirectory>target/greenpepper-reports</reportsDirectory>
                    <systemUnderDevelopment>com.greenpepper.systemunderdevelopment.GreenPepperSystemUnderDevelopment</systemUnderDevelopment>
                    <resources>
                        <resource>
                            <directory>src/fixture/resources</directory>
                        </resource>
                    </resources>
                    <repositories>
                        <repository>
                            <type>com.greenpepper.runner.repository.GreenPepperRepository</type>
                            <root>
                                <![CDATA[http://www.greenpeppersoftware.com/confluence/rpc/xmlrpc?handler=greenpepper1&sut=GreenPepperOpen - Core Java&includeStyle=true]]>
                            </root>
                            <name>greenpepper</name>
                            <suites>
                                <suite>GreenPepper Confluence-GREENPEPPER</suite>
                            </suites>
                        </repository>
                    </repositories>
                </configuration>
                <executions>
                    <execution>
                        <id>greenpepper</id>
                        <goals>
                            <goal>compile</goal>
                            <goal>resources</goal>
                            <goal>fixture-jar</goal>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Specifications documents as HTML files

Example of a file system repository:
In this example, the specifications are under the directory ${basedir}\src\fixture\specs (which correspond to the root element). For each repository, the specifications are under the directory Demo and DemoPhoneBook.

<build>
    <plugins>
        <plugin>
            <groupId>greenpepper</groupId>
            <artifactId>greenpepper-maven-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
                <fixtureSourceDirectory>src/fixture/java</fixtureSourceDirectory>
                <fixtureOutputDirectory>target/fixture-test-classes</fixtureOutputDirectory>
                <systemUnderDevelopment>com.greenpepper.confluence.demo.DemoSystemUnderDevelopment</systemUnderDevelopment>
                <resources>
                    <resource>
                        <directory>src/fixture/resources</directory>
                        <excludes>
                            <exclude>**/*.java</exclude>
                        </excludes>
                    </resource>
                </resources>
                <repositories>
                    <repository>
                        <name>Demo</name>
                        <type>com.greenpepper.repository.FileSystemRepository</type>
                        <root>${basedir}/src/fixture/specs</root>
                        <suites>
                            <suite>Demo</suite>
                        </suites>
                    </repository>
                    <repository>
                        <name>DemoPhoneBook</name>
                        <type>com.greenpepper.repository.FileSystemRepository</type>
                        <root>${basedir}/src/fixture/specs</root>
                        <suites>
                            <suite>DemoPhoneBook</suite>
                        </suites>
                    </repository>
                </repositories>
            </configuration>
            <executions>
                <execution>
                    <id>greenpepper</id>
                    <goals>
                        <goal>compile</goal>
                        <goal>resources</goal>
                        <goal>fixture-jar</goal>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

You can found the project of this example here.
try anonymous/anonymous if asked for a password

Command line options

To skip the execution of the GreenPepper tests :

-Dmaven.greenpepper.test.skip=true

To change the report type (default to html) :

-Dmaven.greenpepper.reports.type=xml

To stop the execution on the first failure :

-Dmaven.greenpepper.test.stop=true

To active the debug mode :

-Dmaven.greenpepper.debug=true

To ignore failures during the execution (will not stop Maven with an error) :

-Dmaven.greenpepper.test.failure.ignore=true

Sonar

Sonar is an open platform to manage code quality.

The Sonar GreenPepper Plugin collects test reports provided by GreenPepper Maven plugin to feed Sonar.

To produce GreenPepper test reports, the easiest way is :

mvn clean integration-test sonar:sonar
The integration-test will trigger the greenpepper:compile, greenpepper:resources, greenpepper:fixture-jar and the greenpepper:run goals.

Make sure to produce report in XML format by adding

<reportsType>xml</reportsType>
to the Maven GreenPepper configuration or by specifying
-Dmaven.greenpepper.reports.type=xml
on the command line of Maven

Failures

The GreenPepper Maven plugin will stop when a failure is detected and will abort Sonar execution. To prevent this, specify

-Dmaven.greenpepper.test.failure.ignore=true
on the command line

Executing specification fixtures (GreenPepper Open Documentation Refactoring )
Maven plugin examples (GreenPepper Open Documentation Refactoring )
Maven plugin goals (GreenPepper Open Documentation Refactoring )
Maven plugin options (GreenPepper Open Documentation Refactoring )
Sonar (GreenPepper Open Documentation Refactoring )

DEMONSTRATION LICENSE - This Confluence site is for demonstration purposes only. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.4.3 Build:#705 Mar 21, 2007) - Bug/feature request - Contact Administrators