Common mistakes in tdd can you guess
-
Upload
christos-matskas -
Category
Software
-
view
576 -
download
0
Transcript of Common mistakes in tdd can you guess
Common mistakes in TDD - can you guess?
Christos Matskashttps://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 time to do bug fixes and add new features•Reduces debugger-driven development•Makes the code more adaptable
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) { return studentRepository.GetByID(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 GetAllUsers() { return new UserView(userService.GetAllUsers()); }}
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?
Questions?