TestingDocs.com
Software Testing website
  • JBehave
  • Selenium
  • Testlink
  • Maven
  • Git
  • RAPTOR
  • Questions

Configure JBehave Stories

Tweet
Pin it

Document Contents

  • Introduction
  • MostUsefulConfiguration
  • Adding Step Instance
  • Running JBehave Stories
  • Reports

Introduction

In this post, we will learn how to configure JBehave Stories. If you are a beginner to JBehave, read more here about it ( What is JBehave Framework? ).

MostUsefulConfiguration

Configuration is an abstract class that can be viewed as a Builder pattern. It provides the configuration used by the Embedder and the in the Embeddable implementations to customize the runtime properties. Also, each element of the configuration can be specified individually, and read well. Furthermore, all elements have default values, which can be overridden by the “use” methods. The “use” methods allow overriding the dependencies one by one.

MostUsefulConfiguration is a subclass of Configuration. As mentioned above, we can specify and override many use methods to alter the runtime behavior of how we configure stories and steps. For example, story loading, step finder, failure strategy, pending steps strategy etc.

Adding Step Instance

I have added the step instance of the Calc story as below:

@Override
    public List<CandidateSteps> candidateSteps() {
        return new InstanceStepsFactory(configuration(), new AddSteps())
                .createCandidateSteps();
    }

 

The minimal default configuration as shown below:

 new MostUsefulConfiguration().useStoryLoader(
     new LoadFromRelativeFile(storyURL)).useStoryReporterBuilder(
     new StoryReporterBuilder().withDefaultFormats());
    }

 

Running JBehave Stories

We can run the Jbehave story in many ways using IDE’s and tools using JUnit. We can also use the Embedder class. Embedder is a facade pattern, which allows the functionality to be embedded into other run contexts, such as IDE via using JUnit,  Maven, etc.

The above configuration method loads the default configuration for running the tests. Override the Junit run method to run the story as shown below. Now running the test is simple, select Run As > JUnit Test.

@Override
    @Test
    public void run() {
        try {
            super.run();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }

 

Reports

Consolidated Story report ( reports.html ) can be found under the target view folder.

 

Jbehave Story Reports
Jbehave Story Reports

 

JBehave Tutorials on this website can be found at:
https://www.testingdocs.com/jbehave-framework-tutorial/

For more details on the JBehave framework, visit the official JBehave website at:
http://jbehave.org

Related Posts

JBehave /

Cucumber Java BDD Selenium Framework

JBehave /

JBehave + Serenity Sample Project

JBehave /

Serenity BDD Automation Framework

JBehave /

Serenity Maven Artifacts

JBehave /

Introduction to Serenity BDD

Tag Cloud

Agile Appium Tutorials C++ Eclipse Tutorials Git Tutorials IntelliJ Tutorials Java Java Tutorial JBehave Jenkins Jira Cloud JUnit Tutorial Maven Object-oriented Flowchart Python Tutorials Raptor Flowcharts Selenium IDE TestLink Tutorials

Random Posts

  • TestLink Bitnami Cloud Image
    Overview In this tutorial, we will see the steps

    Read more

  • Code Coverage Tools
    Overview Let’s look at some of the code coverage

    Read more

  • pCloudy Continuous Testing Cloud
    Overview pCloudy is a continuous testing cloud

    Read more

Back to Top

TestingDocs.com

  • Privacy Policy
  • Cookie Policy
  • JBehave
  • Selenium
  • Testlink
  • Maven
  • Git
  • RAPTOR
  • Questions
www.TestingDocs.com | All Rights Reserved