AAA: The Shape Of A Readable Test
Structure a unit test using Arrange, Act, Assert so the behavior under test is obvious.
The move: let a future reader find the behavior in five seconds. AAA is not about comments. It is about shape. Arrange answers, what world does this behavior need? Act answers, what behavior are we testing? Assert answers, what must be true afterwards? When these are blended together, the test can still pass, but it becomes harder to trust and harder to fix. A strong Arrange block is boring and explicit. It names only the state the behavior needs. A strong Act block usually has one line. A strong Assert block checks the outcome in terms of behavior, not incidental…
Sign up free — one personalized lesson every day, matched to your role and goals.
Already have an account? Sign in