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.
Remember to include jbehave-ant to your runtime classpath.
Note: we are using as default scope compile, which means that the scenarios will be looked up in the source directory (which can be optionally specified and defaults to src/main/java). If the scope is set to test the scenarios will be looked up in the test source directory (which can be optionally specified and defaults to src/test/java).
Note: we are using as default scope compile, which means that the scenarios will be looked up in the POM source directory. If the scope is set to test the scenarios will be looked up in the POM test source directory.
Both Ant and Maven by default instantiate the Scenario class via a public constructor with a single ClassLoader parameter (i.e. with property classLoaderInjected set to true). This allows the scenario to be injected with the class loader during instantiation, e.g. as used in the loading of I18n resource bundles. If the user does not require the class loader during instantiation, its injection can be disabled by setting the property classLoaderInjected to false. In this case only the default public constructor is required.
By default, the scenario runners are configured to fail-fast, i.e. the execution will stop at first failure (but will complete execution of the all the scenarios in the story or textual scenario file). To allow the generation of complete reports view, the runners need to be enabled to execute scenario in batch and ignoreFailure modes (i.e. setting these flags to true). In this way all scenarios will run and the build will be nominally successful but a full report can ben generated, including the failed and pending steps. Note that the batch mode is strictly speaking not essential but makes it easier to get a summary of the failed scenarios.