Skip to main content

Development

Serenity and Cucumber Make Automation Testing Vivid

Do product owners and business analysts complain about complex testing scripts when you work through acceptance criteria together?

Do you stress about maintaining the complex testing framework?

Do you write codes to generate a better HTML report?

 A good automated testing framework can be used by testers and business people without programming skills. It’s also easier to maintain. Behavior driven development can help to resolve this problem.

Cucumber is a popular BDD tool, but users have to define the backend framework and the reporting is not very user-friendly.

Serenity is another open source BDD testing framework and it can be used together with Cucumber.

Do product owners and business analysts complain about complex testing scripts when you work through acceptance criteria together?

Cucumber organizes testing steps and verification points in feature files. The scenarios and features can be grouped by high-level concepts, such as epics. In Agile terms, the user story might look like this:

“As a buyer, I want to be able to add the searched products to a cart so that I can buy them together.”

Cucumber describes requirements with epics, features, scenarios, and steps.  Steps, are also known as Given, When and Then. The details following step key words are defined by users, so it is easier to read for your testers and business people. Test cases can be delivered by features directly as below.

Feature: AddtoCart

Asauser,Iwanttosearchaproductandaddittomycart.

ScenarioOutline: Usercansearchoutproductandaddtocartsuccessfully

GivenIcansearchoutproduct’<keywords>

ThenIcanaddproducttocartwith’<quantity>

AndIcansee'<quantity>’ofproductsincart

Are you stressing about maintaining the complex testing framework?

Serenity BDD helps you write cleaner and more maintainable automated acceptance and regression tests faster. Serenity BDD has a defined PageObject class. It hides WebDriver logic in “Page objects”. The JUnit Serenity integration provides special support for Serenity Page Objects. In particular, Serenity will automatically instantiate any PageObject fields in your JUnit test.  Serenity also has a ScenarioSteps class, and it is a parent of every steps class. It can be used in steps definition. The web driver is started at the start of the scenario and closed at the end of scenario automatically.  Common web driver methods have been defined in the Serenity PageObject.

1

Testing code focuses on business logic without webdriver management exposing. The web driver properties can also be configured.

2

Are you writing codes to generate a better HTML report?

 Serenity also uses the test results to produce illustrated, narrative reports that document and describe what your application does and how it works. Serenity maven plugin can aggregate report  features together.

The user can see the testing result of every feature, scenario, and steps. The test data and the screenshot of every step are also listed in the report.

3

The statistics of an overall testing result are also generated automatically.

4

This should resolve many of your concerns. In following posts, we will discuss more about webdriver configuration, test data management, distribution test, CI integration and useful annotations.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Cathy Zhang

More from this Author

Categories
Follow Us