Running Scenarios

JBehave was designed to be embeddable in different development environments. The JBehave Core module contains support for running scenarios as JUnit tests - which can be run either in your favourite IDE or in your command-line build that supports JUnit tests. Other unit testing frameworks, e.g. TestNG, can also be used very easily, c.f. FAQ.

You can also run scenarios using the JBehave Ant or Maven extensions. Both support two way to lookup scenarios, by list of scenario classes or by Java path includes/excludes pattern. Below are examples on how to configure both extensions - using the trader example.

Running as Ant task

  
  
  
    

Remember that you need to include jbehave-ant to your runtime classpath.

Running as Maven Plugin

   
        org.jbehave
        jbehave-maven-plugin
        [version]
        
          
            run-scenarios-found
            integration-test
            
              
                **/scenarios/*.java
              
              
                **/*Steps.java
              
              [true|false] 
              [true|false]
              [compile|test]
            
            
              run-scenarios
            
          
        
    

NOTE: Running scenarios with Maven requires each Scenario class to have a constructor with a single ClassLoader parameter. Maven uses this constructor to instantiate the Scenario class using the classpath constructed with the POM depedendencies.