Common mistakes in tdd can you guess

20
Common mistakes in TDD - can you guess?

Transcript of Common mistakes in tdd can you guess

Page 1: Common mistakes in tdd   can you guess

Common mistakes in TDD - can you guess?

Page 2: Common mistakes in tdd   can you guess

Christos Matskashttps://cmatskas.com@christosmatskas https://github.com/cmatskas

Page 3: Common mistakes in tdd   can you guess

What is Test Driven Development (TDD)?

Page 4: Common mistakes in tdd   can you guess

What TDD isn’t

• TDD tests are not Unit Tests

• TDD tests are not User Acceptance Tests

Page 5: Common mistakes in tdd   can you guess

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

Page 6: Common mistakes in tdd   can you guess

Common TDD mistakes

#1

Not using a Mocking Framework

Page 7: Common mistakes in tdd   can you guess

Common TDD mistakes

#2

Too much test setup

Page 8: Common mistakes in tdd   can you guess

Common TDD mistakes

#3

Asserting everything

Page 9: Common mistakes in tdd   can you guess

Common TDD mistakes

#4

Unnecessary testing

Page 10: Common mistakes in tdd   can you guess

Unnecessary testing - example

public class StudentService(){ //….other code ommitted public Student GetByID(string id) { return studentRepository.GetByID(id); }}

Page 11: Common mistakes in tdd   can you guess

Larger issues with TDD

#1

False confidence

Page 12: Common mistakes in tdd   can you guess

Larger issues with TDD

#2

Testing too much is expensive

Page 13: Common mistakes in tdd   can you guess

Larger issues with TDD

#3

Test induced architecture damage

Page 14: Common mistakes in tdd   can you guess

Larger issues with TDD

#4

Heavy Mocking

Page 15: Common mistakes in tdd   can you guess

Larger issues with TDD

#5

TDD in the real world

Page 16: Common mistakes in tdd   can you guess

Larger issues with TDD

#6

No everyone can think in TDD terms

Page 17: Common mistakes in tdd   can you guess

Make TDD work for you

Use the right tool for the job

Page 18: Common mistakes in tdd   can you guess

TDD with Model-View-Controller(MVC)

public Controller UserController(){ //...other code ommitted public IHttpViewResult GetAllUsers() { return new UserView(userService.GetAllUsers()); }}

Page 19: Common mistakes in tdd   can you guess

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?

Page 20: Common mistakes in tdd   can you guess

Questions?