San Francisco Software Craftsmanship Meetup
Test Driven Developers Bay Area Meetup
TDD Flow: The Mantra in Action” is a talk + hands-on about the mantra of TDD and its core patterns. Here are some questions for this talk: What is TDD? How to write a good test that fails? How to write code enough to make the test pass? How to remove duplication? How to refactor code? How to create clean code? Is TDD about testing or design? How small should a test be? Should I only write unit tests? Should I estimate TDD? How to use TDD with other agile methods like Scrum, Kanban or BDD? And finally, how to flow in TDD?
7. TDD is the shortest cycleTDD is the shortest cycle
in agile developmentin agile development
8. TDD Rules
1. Write new code only if you first
have a failing automated test
2. Eliminate duplication
9. Write a small automated
test that fails
Red
Code just enough to
make the test pass
GreenRemove duplication and
refactor to clean code
Refactor
The Mantra in Action!
12. Refactoring
To restructure
software by applying a
series of refactorings
without changing its
observable behavior.
Martin Fowler
http://martinfowler.com
TDD = TFD + Refactoring;
26. Red Bar Patterns
One Step Test
Which test should I pick from
the list?
Learning X Confidence
27. Red Bar Patterns
Starter Test
Which test should I start?
By a variation of the operation that doesn’t do
anything, returning a constant.
Outside-in (skeleton)
28. Red Bar Patterns
Explanation Test
How to spread test automation?
Ask for and give explanations in terms of tests.
29. Red Bar Patterns
Learning Test
How to learn from externally
produced software?
Write a test before use that software.
30. Red Bar Patterns
Another Test
How to discuss something off
topic?
Add a test to the list,
and go back to the current test.
36. Testing Patterns
Child Test
How to get a too big test case running?
Write the smallest test case that represents the
broken part of the bigger test case, and make it run.
Go back to the big test case.
37. Testing Patterns
Mock Object
How to test something that relies on an
expensive or complicated resource?
Create a fake version of the resource.
38. Testing Patterns
Crash Test Dummy
How to test error codes difficult to be
invoked?
Create a fake object for that.
48. xUnit Patterns
Assertion
Boolean expressions with assert();
Fixture
Common objects for the tests with setUp();
External Fixture
Release external resources with tearDown();
Test Method
Represents a test case
Exception Test
Fail(); if the exception is not thrown
AllTests
Suite of all suites
57. “To me the essence of the
question I think about that,
thinking about software design, I
don't care about TDD or not TDD.”
Kent Beck, Is TDD dead? Part II.