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

@BeforeStories / @AfterStories JBehave Annotations

Tweet
Pin it

Document Contents

  • Overview
  • @BeforeStories and @AfterStories
  • Example code snippet

Overview

In this post, we will discuss Jbehave annotations @BeforeStories and @AfterStories . If you are familiar with TestNG framework these annotations are somewhat similar to @BeforeSuite and @AfterSuite.

@BeforeStories and @AfterStories

The @BeforeStories and @AfterStories annotations allow the methods to be executed before and after stories respectively. Also, any initialization code before executing stories goes into @BeforeStories method. In addition, any clean-up code that needs to be run after all the stories have run goes into @AfterStories. Furthermore, the below picture attempts to clarify the concept.

 

@BeforeStories
Before Stories

Any initialization setup code should be written in this annotated method. For example, opening a db connection, reading and setting Jbehave configuration etc…

Example code snippet

@BeforeStories
public void storiesInit() {
    System.out.println("BeforeStories......");
    // initialization setup code goes here …. This code executes before all stories 
    // for example you may open a db connection etc...
}

 

@AfterStories
public void storiesCleanUp() {
System.out.println("AfterStories......");
// cleanup code goes here …. This code executes after all stories have run
// for example you may archive run reports , close db connection etc...
}

 

All the cleanup code should go here in this code block. This code executes after all the stories have run. Examples that go here are closing db connections , archiving the results , sending stats metrics, any clean up code that you may be interested in

 

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

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

Latest Tweets

Tweets by @TestingDocs

Back to Top

TestingDocs.com

Privacy Policy

Cookie Policy

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