My 25 Laws of Test Driven Development - Dennis Doomen - NDC Porto 2023

Dennis Doomen shares his 25 laws of Test Driven Development, providing practical advice on how to implement effective testing strategies, from writing clear test names to utilizing dependency injection and refactoring early and often.

Key takeaways
  • Always put an implementation of a rule or principle in code to reinforce understanding
  • Test smaller, initially simpler test cases, then build upon them
  • Each unit test should have a clear name that implies the intention
  • Treat tests as documentation, keep them simple, clear, and focused
  • Use fluent assertions instead of using magical numbers
  • For complicated scenarios, create a function or a class to break it down
  • Implement IComparable for equality checks
  • Utilize dependency injection to manage dependencies
  • Refactor early and often
  • Use automated testing tools to accelerate continuous testing
  • The principle of dependency versioning helps in reducing coupling
  • People tend to over-engineer, rather than maintainable code
  • Naming should be descriptive and follow a coherent definition
  • Test at the edge of your system, not inside it, using tools like EventStore
  • Non-test code should be simple and maintainable, not unwieldy
  • No one expects interfaces to stay the same, so tests should be flexible
  • All code should be able to be debugged, even when reviewing pull requests
  • The importance of automated testing for timely feedback
  • End-to-end testing might be slow, but it can catch complex issues
  • Ensure that your tests are self-documenting
  • TDD can also be used to create examples of how to use your code
  • Mocking can be useful, but it can also lead to bad code
  • Automatic testing can reduce the need for manual debugging