Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Common mistakes in TDD -
can you guess?
Christos Matskas
https://cmatskas.com
@christosmatskas
https://github.com/cmatskas
What is Test Driven Development (TDD)?
What TDD isn’t
•TDD tests are not Unit Tests
•TDD tests are not User Acceptance Tests
What does TDD have to offer?
• Small pieces of code
• Short feedback loop
• Helps create design specification
• Reduces ti...
Common TDD mistakes
#1
Not using a Mocking Framework
Common TDD mistakes
#2
Too much test setup
Common TDD mistakes
#3
Asserting everything
Common TDD mistakes
#4
Unnecessary testing
Unnecessary testing - example
public class StudentService()
{
//….other code ommitted
public Student GetByID(string id)
{
...
Larger issues with TDD
#1
False confidence
Larger issues with TDD
#2
Testing too much is expensive
Larger issues with TDD
#3
Test induced architecture damage
Larger issues with TDD
#4
Heavy Mocking
Larger issues with TDD
#5
TDD in the real world
Larger issues with TDD
#6
No everyone can think in TDD terms
Make TDD work for you
Use the right tool for the job
TDD with Model-View-Controller(MVC)
public Controller UserController()
{
//...other code ommitted
public IHttpViewResult G...
Make TDD work for you
• Code-to-test radio => 1:2
• Find the right coverage ratio
• Test should take less time to write th...
Questions?
Upcoming SlideShare
Loading in …5
×

Common mistakes in tdd can you guess

649 views

Published on

Slides for my talk on TDD, the usual mistakes that developers make when practising TDD, the wider issues in TDD and suggestions how to make TDD work better

Published in: Software
  • Be the first to comment

Common mistakes in tdd can you guess

  1. 1. Common mistakes in TDD - can you guess?
  2. 2. Christos Matskas https://cmatskas.com @christosmatskas https://github.com/cmatskas
  3. 3. What is Test Driven Development (TDD)?
  4. 4. What TDD isn’t •TDD tests are not Unit Tests •TDD tests are not User Acceptance Tests
  5. 5. What does TDD have to offer? • Small pieces of code • Short feedback loop • Helps create design specification • Reduces time to do bug fixes and add new features • Reduces debugger-driven development • Makes the code more adaptable
  6. 6. Common TDD mistakes #1 Not using a Mocking Framework
  7. 7. Common TDD mistakes #2 Too much test setup
  8. 8. Common TDD mistakes #3 Asserting everything
  9. 9. Common TDD mistakes #4 Unnecessary testing
  10. 10. Unnecessary testing - example public class StudentService() { //….other code ommitted public Student GetByID(string id) { return studentRepository.GetByID(id); } }
  11. 11. Larger issues with TDD #1 False confidence
  12. 12. Larger issues with TDD #2 Testing too much is expensive
  13. 13. Larger issues with TDD #3 Test induced architecture damage
  14. 14. Larger issues with TDD #4 Heavy Mocking
  15. 15. Larger issues with TDD #5 TDD in the real world
  16. 16. Larger issues with TDD #6 No everyone can think in TDD terms
  17. 17. Make TDD work for you Use the right tool for the job
  18. 18. TDD with Model-View-Controller(MVC) public Controller UserController() { //...other code ommitted public IHttpViewResult GetAllUsers() { return new UserView(userService.GetAllUsers()); } }
  19. 19. Make TDD work for you • Code-to-test radio => 1:2 • Find the right coverage ratio • Test should take less time to write than actual code • Keep clear separation between unit & integration tests • Find the best approach to code first (30:70?
  20. 20. Questions?

×