chapter eighteen

18 Dress rehearsal patterns for building confidence

 

This chapter covers

  • The challenges of testing an application that uses external services
  • The benefits of resetting the database before a scenario runs, rather than after it finishes
  • Techniques for ensuring that every scenario starts with the database in the same state
  • Optimizations that allow for fast feedback without compromising the reliable repeatability of automated tests
  • Useful approaches when tests rely on external datasets that are not owned by the team

The patterns described in this chapter are essential when integration testing scenarios that depend on services, such as databases or payment gateways. While developers are encouraged to develop using stubs to get the fast feedback they need, we must also continuously run the scenarios as integration tests to build confidence that there won’t be significant issues during a release.

Definition

Integration testing – the practice of testing various modules of the system under development as a group to ensure that together they behave as expected.

18.1 Challenges of using real databases for test execution

18.2 Reset Before pattern: reset database before scenario execution

18.3 Clean Start pattern: start each scenario with an empty database

18.4 Seeded Data pattern: share common data across scenario executions

18.5 Skippable Reset pattern: do not reset database after read-only scenario executions

18.6 Patterns for snapshot databases

18.6.1 Undo Changes pattern: only reset modified data

18.6.2 Entity Finder pattern: find suitable data instead of creating it

18.7 Summary