Arrange-Act-Assert (AAA) 是一种模式,将测试清晰地结构化为三个阶段:Arrange(准备)、Act(执行操作)、Assert(验证结果)。它使测试可读性强、结构清晰且易于理解。
三个阶段
ARRANGE → set up the test: create objects, prepare inputs, configure mocks, set state
ACT → perform the ACTION being tested (call the function/method under test)
ASSERT → verify the OUTCOME: check the result/behavior matches what's expected
→ A clear three-part structure for every test.
