Nowadays web applications are more and more sophisticated and projects cannot afford long manual testing cycle. 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 produce easy maintainable test suites.
One of these tools is represented by Serenity, an open source reporting framework that help us write better structured and maintainable automated acceptance test. Serenity uses Java coding standards and practices for a good code quality. You may say that the framework forces you to write clean code.
One benefit of using Serenity is represented by 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 key in obtaining an explicit test report. Test result aren’t the only deliverable of the report, features that have been tested are the other main deliverable of the report.
There is more than one way of writing your tests. Serenity supports 4 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, Behavior Driven Development. If you desire a more BDD approach to testing and 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 need to 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”
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 in the web page, bringing order, structure and reusability of mapped objects. Serenity also provide shortcuts to interact with the page, all you need to is writing the WebDriver code that interacts with the pages.
Beside Page Object, in Serenity we have the Step Library which are used to add an abstraction layer in our acceptance test. This approach makes the test easier to understand and maintain.