Search⌘ K
AI Features

Follow the AAA Pattern

Understand how to apply the Arrange-Act-Assert (AAA) pattern in your JUnit tests. This lesson helps you clearly organize tests into three sections to improve readability and maintainability in Java unit testing, ensuring that test setup, execution, and verification are distinctly separated.

We'll cover the following...

When we write tests, we visually organize them into three chunks: arrange, act, and assert, also known as triple-A (AAA).

@Test
public void answersArithmeticMeanOfTwoNumbers() {
   // Arrange
   ScoreCollection collection = new ScoreCollection();
  
...