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:
- The following will copy your resources:
- The following will execute your specifications:
- The following will create you fixture jar:
- The following will download the specification files:
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
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.
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 :
To change the report type (default to html) :
To stop the execution on the first failure :
To active the debug mode :
To ignore failures during the execution (will not stop Maven with an error) :
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 :
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 to the Maven GreenPepper configuration or by specifying 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
on the command line