A multiple-act section is a test execution phase containing more than one operation under verification. It is generally a code smell because the test checks multiple units of behavior, reducing focus and maintainability. section 8.5 section 8.8
Use the following rules when deciding whether multiple acts are justified:
- Split related workflows, such as registration and deletion, into separate tests even when the first result can prepare the second operation. section 8.5
- Never use multiple acts in a unit test; reserve the exception for tests involving out-of-process dependencies that are difficult to reset. section 8.8
- Treat multistep tests as likely end-to-end tests and weigh their broader scope against understandability and modification cost. section 8.8
Registration followed by deletion
A fragile integration test registers a user, asserts successful persistence, deletes the same user, and asserts deletion. Refactor it into one registration test and one deletion test; each test then has a single act and a clearer failure meaning. section 8.5
