link: Unit Testing
Arange-Act-Assert Pattern
Overview
The Arrange-Act-Assert (AAA) pattern is a structured approach to writing unit tests. It divides the test into three distinct sections:
- Arrange: Set up the test environment, including any necessary objects, data, or configurations.
- Act: Perform the action that you want to test.
- Assert: Verify that the action produced the expected results.
This pattern promotes clarity and maintainability by clearly separating the different phases of the test, making it easier to understand and manage.
C# Examples of Unit Tests with AAA Pattern
Testing a Calculator Add Method