3

I am trying to get a JBehave story to execute in Maven it is completely ignoring the JBehave plugin. I've spent several hours using different configurations but it looks like the plugin isn't being executed at all. Any recommendations/tips would be appreciated!

All my JBehave classes live in:

src/at/java

Relevant parts of my pom.xml:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.5</version>
    <executions>
        <execution>
            <id>add-test-source</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>add-test-source</goal>
            </goals>
            <configuration>
                <sources>
                    <source>src/at/java</source>
                 </sources>
            </configuration>
    </execution>
</executions>
</plugin>

<plugin>
    <groupId>org.jbehave</groupId>
    <artifactId>jbehave-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>run-stories-as-embeddables</id>
            <phase>integration-test</phase>
            <configuration>
                <includes>
                     <include>**/*.java</include>
                </includes>
            </configuration>
           <goals>
               <goal>run-stories-as-embeddables</goal>
          </goals>
       </execution>
    </executions>
</plugin>


<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.11</version>
    <executions>
        <execution>
            <id>integration-test</id>
            <phase>integration-test</phase>
            <goals>
                <goal>test</goal>
           </goals>
           <configuration>
               <skip>false</skip>
              <includes>
                   <include>**/*.java</include>
               </includes>
           </configuration>
        </execution>
    </executions>
</plugin>
seedhead
  • 3,655
  • 4
  • 32
  • 38

3 Answers3

2

Best is to change the location of your test classes to src/test/java and change the name of the stories based on the documentation of JBehave.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • 1
    If that is seriously the best solution then that is really disappointing on Jbehaves part. These are tests so why would you want them in src/main/java along with your production code? – Michael W Jun 07 '13 at 07:46
  • 1
    That was a typo. Fixed it. – khmarbaise Jun 07 '13 at 11:17
  • I agree with this answer. Best to follow SDL (Standard Directory Layout) for Maven and allow Surefire to start your JBehave tests. http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html – djangofan Aug 27 '13 at 19:39
1

JBehave running with maven follow the Maven rules for location of code and text artifacts. For test scope you must put them in src/test/java and src/test/resources. For compile scopes is src/main/java and src/main/resources.

With JBehave with maven you could use two scopes (test or compile), you just need to set which one you want in the plugin configuration, so you choose where to put your artifacts. it defaults to compile.

In your case you are adding a new test source so you must set the scope to test:

see detail here.

Cristiano
  • 1,414
  • 15
  • 22
0

Maybe the jbehave-maven-plugin could not find the compiled test classes (scenarios) because it looks in the wrong classpath.

Please look at your target directory and search the embeddable classes -> target/classes or target/test-classes?

To solve the problem i must set the scope of jbehave-maven-plugin to test in the configuration of my project pom.xml.

here is a example

<plugin>
            <groupId>org.jbehave</groupId>
            <artifactId>jbehave-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>run-stories-as-embeddables</id>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>run-stories-as-embeddables</goal>
                    </goals>
                    <configuration>
                        <scope>test</scope>
                        <includes>
                            <include>**/*Scenarios.java</include>
                        </includes>
                        <ignoreFailureInStories>true</ignoreFailureInStories>
                        <ignoreFailureInView>false</ignoreFailureInView>
                    </configuration>
                </execution>
Huluvu424242
  • 756
  • 10
  • 25