There is a definite structure of any test we write. This structure is based on the process that needs to be followed for us to write effective tests. The structure is defined with the acronym AAA, as explained in the following list:
- Arrange: As the name suggests, this is the part where we write the initial state of the unit test. The initial state here means the setup that is required for us to write the test. The setup can be initializing the class, or even setting up the initial set of data.
- Act: This is the step where we act in our class and make a change that is to be tested. So, this can be like calling a function in a class, or changing some property in a class.
- Assert: This is the step where we validate our test. ...