- Bank Account
- Fibonacci Sequence
- Leap Year
- Password Validator
- Phone Numbers
- Bowling Game
- Customer Registration
- Write first a failing test
- Write just enough code to make it pass
- Refactor to improve the code
- Tests should test one thing only
- Don't refactor with a failing test
- Ensure tests are independent of each other
- Organise your unit test projects to reflect your production code
- Give your tests meaningful names
- Create more specific tests to drive a more generic solution (Triangulate)
- See the test fail for the right reason
- Write the assertion first and work backwards
- Organize your test in Arrange, Act and Assert blocks.
- Write the simplest code to pass the test
- Treat tests as first-class code
- Use the IDE to refactor quickly and safely
- Refactor production and test code independently (except changing public interfaces)
- Use the Rule of 3 to tackle duplication
Seed projects to quickly start practicing TDD in different programming languages.
-
Java (Junit 4, AssertJ, Mockito, JUnitParams)
-
Kotlin (Junit 5 test suits. AssertJ, Mockito)
-
Kotlin (Spek or Junit 4 test suits. AssertJ, Mockito, JUnitParams)
-
C# (NUnit, Moq)
-
JavaScript (Jest)
-
TypeScript + Jasmine (Jasmine, Jasmine-Parameterized)
-
TypeScript + Mocha (Mocha, Chai)
-
Python (Pytest)