This article belongs to a How to create Lean Test Automation Architecture for Web using Java libraries series.
This is a series of articles showing how to create lean test automation architecture for web test automation using Java libraries.
Lean means that we will have less code as possible to create realize, maintainable and useful architecture.
Architecture means the organization, features, and configurations that should be present to enable you to create the automated scripts.
This first article will show to you the basic explanation about the necessary elements to create lean architecture.
Architecture is the overall design of the project. It organizes the code into different layers and defines how they will interact with each other.
In Clean architecture, you will organize the project to make it easy to understand and change as the project evolves.
There’s an excellent post by Uncle Bob about The Clean Architecture that will show you a proposed organization based on an application (not a test framework/architecture).
You can use any design pattern to help you to better organize and maintain your code. There are some you can always use to achieve those benefits for a specific task.
You can use the Factory Method pattern to create browser instances because a better test architecture for web test automation should provide an easy mechanism to create them.
You can also use this design pattern to create a Data Factory.
You can use the Builder pattern to create simplify the creation of the complex objects you have in your code, like:
You can use the Singleton pattern reuse the same object instance among your tests, like:
As the Design Pattern, you can use some Testing Patterns that will show the same benefits.
You can use the Base Test to reuse the same behavior in all your tests avoiding code duplication. The best example for the web test automation is the pre and post condition you will always have: create the browser instance opening it, and close it when the test finishes.
It combines the Object Mother and the Fluent Builder into a class to create data for your models. Imagine you have a Payment model wherein your test you will use it to approve or reject depending. The Test Data Factory will create differents Payment objects based on the data, so you can have an amount that won’t be accepted on the approval process, and another that will be accepted.
You can use the Page Object pattern to enhancing test maintenance and reducing code duplication modeling your pages into classes that will be the interface between the code and the UI.
Test code needs to be handled like your production code. You might face problems during the testing execution like:
You can add a logging strategy in your test architecture to easily, analyze, and understand the errors, so you can take action or have historical information about the problems.
You might need to inform your stakeholders about how reliable your application is, showing a user-friendly report that can show all the important metrics, as well as the testing evidence (like screenshots).
The report strategy is required even for you to quickly analyze the test results.
Generate data for the test is one of the most time-consuming actions, even for automated tests, but it is necessary.
We can apply, at least, three different approaches:
This is the most needed feature in a web test architecture today, We need to execute the test as fastest as we can, and to speed up all the test execution, thought a test suite, we need to use a grid infrastructure.
The first step is to either create a parallelisation solution or use an existent one present in the testing library (like JUnit or TestNG).
The second step is to define environment solution. It can be either:
The last item we need to create is the strategy to execute all the scripts. It will require first the definition of your regression testing execution where you will create est suites. Defining this strategy you can control when and where executing the test scripts.
The second part is the pipeline script that you should create dividing into stages to sequentially execute your test suites to get faster feedback on your application reliability.