use-arrange-act-assert-aaa
Installation
SKILL.md
Summary
Structure every test case or test body into three distinct sections:
- Arrange: Set up the test logic (inputs, mocks, data).
- Act: Execute the function or method under test.
- Assert: Verify the results against expected values.
Rationale
- Readability: A consistent visual structure reduces cognitive load when reading tests.
- Debugging: Clearly separates the "setup" failures from the "actual logic" failures.
- Focus: Encourages tests to focus on a single action (one "Act" per test).
Guidance
- Visual Separation: Use blank lines to separate the three sections.
- Comments (Optional): If the test is complex, you can explicitly add
// Arrange,// Act,// Assertcomments, but blank lines are usually sufficient. - Single Act: Ideally, there should be only one logical action in the Act phase.