FAQs

What is BDD?

BDD stands for Behaviour-Driven Development and you can learn more about BBD from our More on BDD page.

What Java version is required by JBehave?

JBehave requires a JDK 1.5 or greater.

How do I use JBehave within my development environment?

Scenarios can be run in IDEs, as JUnit tests.

Scenarios can also be run on command line, see running scenarios. It can also be run via web runner, although the web support is not part of JBehave Core. For more info on web support refer to JBehave Web.

What libraries does JBehave depend on?

Check the dependencies details.

Eclipse can't seem to find annotations if they are contained within a jar

Some versions of Eclipse need to be aware of the JBehave source to enable the JUnit plugin for scenarios, as they canŐt spot the @Test annotation in a class jar. The link to the core sources is available from the download page.

Alternatively, M2Eclipse users can downlaod the sources automatically.

A workaround is to override the runScenario() method annotated with @Test

public class YourScenario extends JUnitScenario {

    @Test
    public void runScenario() throws Throwable {
        super.runScenario();
    }

}

Note that this is only required for the root scenario of all your scenarios.

Can I run my scenarios in IDE with TestNG?

Similarly to the proposed workaround above, you should be able to run with TestNG by simply annotating the runScenario() method in your root Scenario class with the TestNG @Test annotation.

public class YourScenario extends JUnitScenario {

    @org.testng.annotations.Test 
    public void runScenario() throws Throwable {
        super.runScenario();
    }

}

Note that as we don't tend to use TestNG this solution has not been well-tested. If you encounter any issues please let us know.

How do I make my scenarios fail when steps are not matched and are shown as pending?

Configure the PendingErrorStrategy in Configuration

new Configuration(){
   public PendingErrorStrategy forPendingSteps() {
       return PendingErrorStrategy.FAILING;
   }
} 

How do I output all my scenario steps - and not just when a scenario fails?

Configure the ScenarioReporter in Configuration

new Configuration(){
     public ScenarioReporter forReportingScenarios() {
          return new PrintStreamScenarioReporter();
    }
} 

Alternatively, you can use PropertyBasedConfiguration setting system property "org.jbehave.outputall".

Can my steps classes be POJOs?

Yes, one can write steps as POJOs and then create an instance of CandidateSteps via the StepsFactory

    StepsConfiguration configuration = ... // optional configuration
    new StepsFactory(configuration).createCandidateSteps(new TraderSteps()));    

Alternatively, one can extend the Steps class.

Can I insert comments in the textual scenarios?

Yes, one can add them the scenario title, which allows free text up the first keyword of the scenario, e.g. the first Given.

From version 2.4.1, one can also insert ignorable steps between executable steps, using keyword "!--" (which can be changed via I18n properties)

Scenario: This is a description of the scenario, of the intended behaviour and its verification

Given a precondition
!-- This is an ignorable step, used to insert a comment,
which can be multiline, just like any other step!
When something happens
Then outcome is verified