CodeRetreat
With Draven & Judge
Test-Driven Development
A goal is Clean Code!
-
Don’t write a line of new code unless you first have a failing automated test
-
Eliminate duplication
Two rules of TDD
by Kent Beck
-
Write a test…
-
Make it run…
-
Make it right…
A goal is loose coupling!
-
You are not allowed to write any production code unless it is to make a failing unit test pass.
-
You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
-
You are not allowed to write any more production code than is sufficient to pass the one failing unit test.
Three rules of TDD
by Uncle Bob Martin
A goal is documenting!
-
Write a test for the next bit of functionality you want to add
-
Write the functional code until the test passes
-
Refactor both new and old code to make it well structured
Three rules of TDD
by Martin Fowler
A goal is easy refactoring!
About TDD
by James Shore
A goal is fast cycles via small steps!
Coding Rules for Today
-
Strictly follow TDD rules and do fast cycles
-
Don't forget refactoring
-
As delivery doesn't matter, focus on readable Clean Code
-
Test names and bodies must document the implementation
THX
Some advice
Documenting
-
Test naming
-
Include the method under testing
-
Add context, preconditions
-
Write what will happen, the expected behaviour
-
-
Test cases against behaviour
CodeRetreat 2022.04.29
By drawain
CodeRetreat 2022.04.29
- 115