Nowadays Web applications are more and more sophisticated and project managers cannot afford long manual testing cycles. Because of applications complexity, record and play testing tools are not sufficient. These tools produce scripts that are time-consuming for maintaining them each time the applications changes. For this reason, we try to use tools and techniques that generate easily maintainable test suites. One of such tools is Serenity, an open source reporting framework which help us write better structured and maintainable automated acceptance test. Serenity uses Java coding standards and practices for a good code quality. You could say that the framework forces you to write clean code.
Benefits of using Serenity
The main benefit of using Serenity is the meaningful test reports that are generated after running a test. Each report step name is extracted from method names, thus using a clear language when writing the test code is the key to obtain an explicit test report. Test results aren’t the only deliverable of the report, features that have been tested are delivered as well.
Serenity’s project archetypes
There is more than one way of writing your tests. Serenity supports four project archetypes. This means you can write your tests as pure JUnit tests or you can use jBehave or Cucumber. When we talk about Serenity we should mention one of its main core concept, Behaviour Driven Development (BDD). If you desire a more BDD approach to testing and to the newly added screenplay mode, that makes tests look like, well you guessed it a screenplay where you have actors and scenarios. An approach used in projects where conversation and examples are used to understand features that are needed to be build. Let’s take for example a website that sells tires. One important feature would be sorting tires by their dimensions:
“To help customers to find the tires they are looking for
As a seller
I want customers to be able to sort the tires by dimensions”
Page Object patterns
Serenity also makes full use of Page Object patterns, that are inherited from Selenium practices. Page Objects are used to interact with a particular web page. They are defined based on how they are grouped on the web page, bringing order, structure, and re-usability of mapped objects. Serenity also provides shortcuts to interact with the page. All you need to do is to write the WebDriver code that interacts with the pages.
Besides Page Object, in Serenity there is Step Library which is used to add an abstraction layer in our acceptance test. This approach makes the test easier to understand and maintain.
Author: Calin Marchis