TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • 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

  • MS Access Data Types
  • 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

Go to mobile version