TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • TestNG
  • Tools
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

JBehave

@BeforeStories / @AfterStories JBehave Annotations

JBehave

Overview

In this post, we will discuss Jbehave annotations @BeforeStories and @AfterStories . If you are familiar with the 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

‹ Install JBehave Plugins in IntelliJ IDEA IDE› JBehave Ambiguous Steps

Recent Posts

  • Antivirus Products for Windows 11 PC
  • Install CodeBlocks IDE on Windows 11
  • Location Privacy Settings on Windows
  • Windows 11 Virus & Threat Protection
  • Download & Install Python on Windows 11
  • Cumulative Update for Windows 11 Version
  • Test execution speed in Selenium IDE
  • Check Windows 11 Free Upgrade
  • Download IntelliJ IDE on Windows 11
  • New MySQL Connection in Workbench

Back to Top

Automation Tutorials

  • JBehave Tutorial
  • Selenium Tutorial
  • TestNG Tutorial
  • JUnit Tutorial

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version