Maven

Using the jBehave Maven plugin

The Maven 2 plugin provides several goals, which can be easily attached to a given build lifecycle phase (eg integration-test).

Goal configuration

To run a goal the general configuration is


<build> <plugins> …. <plugin> <groupId>org.jbehave</groupId> <artifactId>jbehave-maven-plugin</artifactId> <executions> <execution> <phase>integration-test</phase> <goals> <goal>[goal-name]</goal> </goals> <configuration> [goal-configuration] </configuration> </execution> </executions> </plugin> </plugins>
</build>

Behaviour Goals

Behaviours (classes implementing the interface org.jbehave.core.behaviour.Behaviours) can be run via the goal ‘run-behaviours’ with configuration:


<configuration> <behavioursClassName>[your Behaviours class name]</behavioursClassName>
</configuration>

The goal will verify all the behaviours specified by the Behaviours class.

Story Goals

Story goals in general apply to one or more text-rendered stories that are found in the classpath.

The goals are:

  • run-story
  • print-story
  • generate-story-code

The story goals will read the story from the path provided, parse it into a org.jbehave.core.story.domain.Story and process it.

The root story package needs to be set in the story file.

The possibile configurations that applies to all goals are:

h4. single story


<configuration> <storyPath>[path of your story file in your classpath]</storyPath>
</configuration>

h4. multiple stories


<configuration> <storyIncludes> <storyInclude><strong>*/</strong>.story</storyInclude> </storyIncludes> <storyExcludes> <storyExclude>**/excluded.story</storyExclude> </storyExcludes>
</configuration>

Running goals in compile or test scope

The plugins supports two scopes: compile (default) and test. In test scope, the classpath is determined from the Maven test scope. To run goals in test scope:

<configuration>
  <scope>test</scope>
</configuration>

Configuring the Maven 2 plugin repositories

The stable versioned releases of the jBehave Maven 2 plugin are automatically synched with the Central Maven Repositories.

If you want to be independent of the synching schedule or want to access the snapshot releases, you can add the following configuration to the POM (typically your parent POM):

   <pluginRepositories>
        <pluginRepository>
            <id>codehaus-plugin-repository</id>
            <name>Codehaus Plugin Repository</name>
            <url>http://repository.codehaus.org</url>
        </pluginRepository>
        <pluginRepository>
            <id>codehaus-plugin-snapshot-repository</id>
            <name>Codehaus Plugin Snapshot Repository</name>
            <url>http://snapshots.repository.codehaus.org</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>