Behavior Driven Development

Serenity is an open source ATDD (Acceptance test driven development) framework that helps you to write better structured, more maintainable automated acceptance and regression web based tests faster using Selenium 2 WebDriver. Serenity rethinks and extends the potential of ATDD; first by turning automated web tests into automated acceptance criteria, and then by documenting those criteria for collaborative, multidisciplinary teams. Serenity also uses the test results to produce illustrated, narrative reports that document and describe what your application does and how it works. Serenity tells you not only what tests have been executed, but more importantly, what requirements have been tested. One key advantage of using Serenity (Serenity) is that you do not have to invest time in building and maintaining your own automation framework. We can write serenity ATDD framework in simple and plain English that can be easily understandable by all the stakeholders in your project. Different stakeholders are able to view acceptance test at different levels.

We can use the different Behavior-Driven-Development BDD tools or frameworks like Cucumber or JBehave, or simply JUnit with Serenity library. We can also integrate Serenity with requirements stored in an external source such as JIRA or any other test cases management tool, or just use a simple directory-based approach to organize your requirements.

Following are the components of Serenity BDD.

  • Requirement
  • Page Objects
  • Steps
  • Tests

After getting the requirements we create user stories based on requirements. The page object model we used for the web elements on applications pages. The next level of abstraction allows us to unite some methods from Page objects together in Steps methods. Finally the methods from the Steps level entities can be used for an automation tests development. And as a result of the Tests runs you will get detail Reports. In Serenity the test scenarios are present in the user stories file in @Given, @When, @Then format in the src/test/resources/stories directory. The image below explains Architecture of Serenity:

Serenity

Reporting is one of Serenity’s fortes. Serenity not only reports on whether a test passes or fails, but documents what it did, in a step-by-step narrative format that includes test data and screenshots for web tests. Following is the test report generated, when I ran my sample project with JBehave and Serenity. Note how much better the Serenity report is compared to the standard JBehave report.

pic2

 

Conclusion

Serenity is very rich and advanced automated acceptance and regression web based tool.  Other BDD framework like JBehave and Serenity make a great combination. Serenity makes it easier to report on progress using automated scenarios, not just as a reporting tool, but also by tracking the relationship between the requirements that have been defined and the corresponding acceptance tests.

Hope you enjoy ready….have a great day!!

 

Swati Karwa

Automation Test Analyst

Adactin Group