Although extremely important, we are not talking here about unit testing and integration testing, assuming you already know what it is and already apply it, as a developer concerned about the quality of your code.
Creating tests is the easiest and quickest way to test your application and ensure that if any bug appears, you will find it before your client.
Currently, we cannot talk about testing without talking about test automation. The application of the test automation gives quick feedback to the team and maintains the execution of the regression tests continuously.
The approach we can use to take a greater speed in automating, executing and having rapid feedback of the tests is the application of the Test Pyramid, which is a guide for the application of automation in at least three levels: unit, services, and ui (user interface).
The services layer is being divided into three parts: component tests, integration tests, and API tests.
The unit testing layer is the most important layer of our application because we will create tests for the code that we are developing and guarantee its work as expected, even after future maintenance (recommending the use of TDD — Test Driven Development). In this layer, we can apply code coverage analysis and static analysis practices in order to intensify the rapid feedback against a defect that may appear.
The service layer (component, integration, and API) is extremely important nowadays, with a large focus on API testing. Here we apply mocks, stubs, and fakes to give speed in the execution of microservice tests. We also need separate test environment servers, where this can be the closest to a production environment.
The UI (User Interface) layer is also important, especially from a mobile testing perspective where, when a customer encounters an error in an app, it usually removes it. The most important techniques here are automated testing in UI and Visual Regression Testing. In the web part, we need browsers to execute the same test in different ones (IE, Chrome, Firefox, Safari). We need the same for mobile automation testing: iOS and Android devices to ensure the compatibility of our app on these two platforms.
The Agile Testing Quadrant, created by Brian Marick and widely disseminated by Lisa Crispin and Janet Gregory in his book “Agile Testing — A Practical Guide for Testers and Agile Teams” are some practices that can be applied during the activity-focused development of the test. The quadrant is a guide: it is not necessary to perform all the existing practices in it, you can choose one or more depending on your context.
There is no way to talk about DevOps without talking about Continuous Delivery (CD). Without it, we could not even talk about the DevOps culture.
In Continuous Delivery, one of the foundations is the Continuous Testing where we must test all the stages of our development (pipeline) with an initial recommendation applied to unit tests and automated acceptance.
Continuous Delivery enables joint roles between Development, QA, and Operation. An example of evidence-focused collaboration for these roles is:
Now we continue with the pipeline focused on tests, which can be applied in whole or in parts, being:
We can create mocks/fakes/stubs to remove the dependencies and accelerate the test execution.
Tests that focus on the user perspective and knowing as end-to-end testing (e2e). Important to simulate the user journey on the application.
Tests that guarantee the operation against different business rules (happy path, sad/negative path and alternative flows)
From Integration to Functional Testing (end of the pipeline) we have to worry about non-functional tests. Examples of tests are functional: performance, load, security, etc …
And it’s extremely necessary to create an entire automated test architecture to support the continuous, automated, and least-maintenance run possible with:
In order to automate an API, a Web page, and a Mobile front-end, there are open source tools that will help you to quickly and easily build and run tests.
Tool for creating automated tests for an API (REST and XML). Uses an easily and understood DSL based on Gherkin (Given-When-Then).
In the example below, it is possible to see the API through a local endpoint (simulating a production environment) and a mock endpoint created with Java Spark. Creating a mock API by developing the API fixed data returns can give even greater speed in the execution and validation of the different aspects that secure the tests for microservices, especially about contract tests.
It is the best-known tool for the automation of a web page. It also has an easy DSL and is based on four steps for automation:
It is an open-source tool with the same Selenium DSL, but for automation in native or hybrid mobile device apps for iOS or Android.
It supports execution on emulators, real devices, or test labs (cloud), and, in conjunction with Selenium Grid, gives the possibility of creating an internal device grid.
The code for all projects can be found in the repository https://github.com/eliasnogueira/test-automation-javaone-2017
There are test suites for each pipeline step.