4

I'm using jbehave and the jbehave maven plugin to run a set of scenario tests.

Have my test class extending JUnitStories, and everything works nicely. Only issue is, I can't stop running the tests...

Every time I run the maven install goal, it runs the tests. I've tried adding a skip scenarios profile, below, but it doesn't stop the tests from running.

<profile>
    <id>skipScenarios</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>

I've also tried using an exclude tag instead of the skip, and excluding my scenario class, but no luck.

I'd really appreciate any insight, or ideas you guys have! Thanks!

john.harvey
  • 49
  • 1
  • 2

4 Answers4

8

You don't need a profile for this. Just add ${skipTests} to the configuration of the execution like this

<plugin>
   <groupId>org.jbehave</groupId>  
   <artifactId>jbehave-maven-plugin</artifactId>
   <version>${jbehave.core.version}</version>
   <executions>
      <execution>
         <id>unpack-view-resources</id>
         <phase>process-resources</phase>
         <goals>
            <goal>unpack-view-resources</goal>
         </goals>
      </execution>
      <execution>
     <id>embeddable-stories</id>
         <phase>test</phase>
         <configuration>
            <includes>
               <include>${embeddables}</include>
            </includes>
            <excludes />
            <skip>${skipTests}</skip>
            ...

Running mvn -DskipTests will then skip unit tests and JBhehave scenarios.

  • Funnily enough, doesn't work for me: it logs `[DEBUG] (f) skip = true` and happily proceeds with tests. – alf Jan 09 '13 at 13:23
  • I am using maven-release-plugin and I am not able to skip the test case . Could you please help me on this. I am using this command -Dresume=false -Darguments="-DskipTests" release:prepare release:perform. I am using Jenkins for build. – JDGuide Dec 19 '14 at 11:08
1
  1. You had maven-surefire-plugin in your config.
  2. You might want to use property activation for the profile so that you can run it with the command

    mvn -DskipScenarios

  3. You don't even need the skip config if you use a profile and in this profile the executions are not present

Here is a working example:

<profile>
        <id>skipScenarios</id>
        <activation>
            <property>
                <name>skipScenarios</name>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.jbehave</groupId>
                    <artifactId>jbehave-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    </profile>
Balint Pato
  • 1,497
  • 1
  • 13
  • 28
0

Probably you need to first add Meta data to your scenarios, then use Meta filtering to select scenarios you want to run.

This may not be the easiest way, but it is documented clearly in jbehave wiki, and once you have Meta info in place, you will have great flexibility to run tests in any combination you want.

zihaoyu
  • 5,483
  • 11
  • 42
  • 46
0

Still found no maven method to do this.

Easiest way seems to be to add a JVM parameter and use System.getProperty("theconfig") to decide whether or not to run scenarios.

Satisfactory, but not perfect solution.

john.harvey
  • 49
  • 1
  • 2