Three parts of a test

This learning hour is about Arrange - Act - Assert and uses a simpler exercise than AAA.

Learning Goals

Session Outline

Connect: Three facts

What is an automated unit test? Give me three facts about it.

Concept: Three parts of a test

An automated test usually has three kinds of code.

Normally in a unit test you only have one of each section, and they come in that order. If you want to check another thing, add a new test case. Don’t just build more act-assert steps onto the same test case.


Write some test cases for some existing code that already basically works. For example CalcStats. Be sure to structure your test cases using Arrange - Act - Assert. If you find any bugs in the code, please fix them.


Can you think of any advantages of structuring your tests this way, with Arrange - Act - Assert? Are there any situations where it wouldn’t be a good idea? When should you use this?