TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

JBehave

Configure JBehave Stories

JBehave

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.

 

https://www.testingdocs.com/jbehave-mostusefulconfiguration/

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

Create a New Project Eclipse

JBehave /

Cucumber Java BDD Selenium Framework

JBehave + Serenity Sample Project

JBehave /

JBehave + Serenity Sample Project

Serenity BDD Automation Framework

JBehave /

Serenity BDD Automation Framework

Serenity Maven Artifacts

JBehave /

Serenity Maven Artifacts

Introduction to Serenity BDD

JBehave /

Introduction to Serenity BDD

‹ JBehave Ambiguous Steps› Running JBehave Stories : JUnitStory and JUnitStories

Recent Posts

  • Update draw.io on Windows
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com