Great Habits
In this lesson, we introduced a few new TDD habits. Check them out in the following list.
Considerations when Writing a New Test
- Tests should test one thing only.
- Create more specific tests to drive a more generic solution (triangulate).
- Give your tests meaningful names (behavior/goal-oriented names) that reflect your business domain.
- See that the test fails for the right reason.
- Ensure you have meaningful feedback from failing tests.
- Keep your tests and production code separate.
- Organize your unit tests to reflect your production code (similar project structure).
- Organize your test in arrange, act, and assert blocks (new habit).
– Arrange (also known as Given) all necessary preconditions.
– Act (also known as When) on the subject under test.
– Assert (also known as Then) that the expected results have occurred.
- Write the assertion first and work backward (new habit).
– Write...