BDD stands for Behaviour-Driven Development and you can learn more about BBD from our More on BDD page.
JBehave requires a JDK 1.5 or greater.
Stories can be run in IDEs, as JUnit tests.
Stories can also be run on command line, see running stories. 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.
Check the dependencies details.
Some versions of Eclipse need to be aware of the JBehave source to enable the JUnit plugin for stories, 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 simple workaround is to override the JUnitStory run() method annotated with @Test
public class YourStory extends JUnitStory { @Test public void run() throws Throwable { super.run(); } }
Note that this is only required for the root class of all your stories.
JBehave comes bundled with out-the-box JUnit support but has no tie-in to JUnit. You can easily configure JBehave stories to run with other testing framework, such as TestNG or Spring's Test module (see developing stories for more details).
A quick workaround to run with TestNG is simply to annotate the run() method in your root JUnitStory class with the TestNG @Test annotation:
public class YourStory extends JUnitStory { @org.testng.annotations.Test public void run() throws Throwable { super.run(); } }
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.
Configure the PendingStepStrategy: in Configuration
new MostUsefulConfiguration().usePendingStepStrategy(new FailingPendingStepStrategy());
Configure the StoryReporter in Configuration
new MostUsefulConfiguration().useStoryReporter(new SilentSuccessFilter(ConsoleOutput()));
Alternatively, you can use PropertyBasedConfiguration setting system property "org.jbehave.outputall".
Yes, one can write steps as POJOs and then create an instance of CandidateSteps via the StepsFactory
Configuration configuration = ... // optional configuration new InstanceStepsFactory(configuration, new TraderSteps()).createCandidateSteps());
Alternatively, one can extend the Steps class.
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