Chapter 6. Automate Tests
Beware of bugs in the above code; I have only proved it correct, not tried it.
Donald Knuth
Best Practice:
-
Write automated tests for anything that is worth testing.
-
Agree on guidelines and expectations for tests and keep track of test coverage.
-
Automated tests help to find and diagnose defects early and with little effort.
The advantages of automation are easy to recognize. Automated tasks are effortless to run. The more often an automated task is executed, the more you are saving. In addition to saving time and effort for repeating the same tasks, it also removes opportunity for error. Therefore it adds reliability to your development process. This leads to less rework and thus faster development. Of course, to automate something, you need to invest in the automation itself and its maintenance (maintaining test code, script, test data, etc.). After the investment, you save time at each repeat. You should aim to automate as much as feasible in the development pipeline, as that gives developers more time to spend on other, creative tasks. You should also make it easy for yourself by using testing frameworks and tooling as much as possible.
Testing tasks are excellent candidates for automation. Table 6-1 provides a summary of the different testing types.
Type | What it tests | Why | Who |
---|---|---|---|
Unit test |
Behavior of one unit in isolation |
Verify that units behave as expected |
Developer (preferably of the unit) |
Integration ... |
Get Building Software Teams now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.