Both the development and integration of services are becoming increasingly agile and decentralized. Systems are in a constant state of flux and yet must be ready for use at all times. To prevent errors and incompatibilities from arising just as quickly with the increased speed and flexibility, an automated approach to testing is essential.
Author: Benjamin Bürgisser
In the old IT world with its fixed project phases, testing usually took place strictly after development and immediately before delivery. This often involved a separate team that was not involved in the development. A few manual end-to-end tests later it was clear: This solution does not work yet.
With increasing speed, these time-honored software lifecycles and fixed release dates are receding into the background. Planning, development, testing and delivery of a service no longer happen in separate phases, but are performed continuously and often by a single DevOps team (see Figure 1). And because individual services and software components are rarely in a vacuum, agile integration is becoming increasingly important. Systems and their components evolve independently, are at different stages of development, and yet must always be able to interact with each other. To learn more about agile integration and its success factors, the articles by Thomas Stuber are recommended at this point: Forms of agile integration - an overview and 5 Learnings for agile integration. A particularly important factor for agile integration is its decentralization. How this can be achieved through integration as a microservice can be seen in the following article by Oliver Faust: Integration as a Microservice.
The advantages of the agile approach are obvious: software systems are ready for use more quickly, potential deficits are identified earlier, changed requirements and new customer wishes are taken into account immediately, and errors are eliminated more quickly.
But it is precisely this speed that also harbors dangers. Without appropriate measures, not only the desired functions and improvements are in the productive environment more quickly, but also undesirable side effects and bugs. The elimination of one bug causes a new one in another place, the integration of one new feature renders another unusable, and the adaptation of the interface for service A causes a breaking change for service B.
In the new agile IT world, testing therefore takes on a central role. Testing is the only way to ensure that software remains executable and continues to interact correctly with other systems, even in the face of continuous change. However, separate testing teams and manually executed end-to-end tests can hardly manage such an undertaking. New solutions are required and, true to the agile approach, these are also quickly adapted, always up to date and executable at any time.
So tests should always be up-to-date and relevant, detect problems early and, most importantly, be executed automatically and quickly whenever changes are made to the code base. Code that is not executable, contains errors or leads to breaking changes at the customers and surrounding systems should not be able to be delivered and put into production in the first place.
This results in two main tasks:
To write the right tests, the test pyramid can be consulted. This can be seen in Figure 2 and recommends a hierarchical approach to identify problems as early as possible. Tests on the lower levels of the pyramid have the highest number of test cases, are created early in the development and are executed regularly. Tests on the upper levels follow later, are more complex, more difficult to automate and usually exist in smaller numbers.
Unit tests are simple, easy-to-automate tests that test the individual components of a software (units) in isolation from each other. Dependencies are replaced by mocks to keep any influences and consequential errors of other units away from the tested unit. Unit tests are white-box tests, so we know the inner workings of our system and its components.
Various tools can assist with automated unit tests. Here are the two most important ones:
Integration tests enable error-free agile integration
Tested and correctly functioning components (units) are the prerequisite for integration tests, which ensure the correct interaction of interdependent services of an overall system. At this point, the individual service is regarded as a black box. Thus, it is no longer the correct internal functioning that counts, which has already been ensured by the unit tests. Instead, we look at the interaction of our service with other services via the respective interfaces.
Here, too, various tools provide support:
After the tests are written according to the test pyramid, it is now a matter of executing them automatically and thus preventing an untested and potentially buggy code from entering the production build. Here, too, various tools provide support:
Focusing more on tests and test automation as a key success factor in agile integration pays off in the long run. Because what looks like extra work at the beginning will more than pay off later in terms of quality and operating costs as well as agility in development and integration.
Specifically, we enable through automated testing:
To achieve these goals, we can implement the following measures:
Sie möchten Ihr Unternehmen mit DevOps voranbringen, wissen aber noch nicht genau, wie Sie es angehen sollen?