Leanpub Header

Skip to main content

Learn Test Driven Development

English Edition

You could use the book as support material for a TDD course. Each kata was selected and oriented to exemplify an specific point in the test driven development process.

This book is a translation into English of Aprende Test Driven Development which was originally written in Spanish

The authors are letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
About

About

About the Book

Book to help to learn TDD, with several proposals of sequenced katas to address several details of the methodology. Katas are organized in formulation, resolution examples and a complete explanation of the main point illustrated with the exercise.

Share this book

Categories

License

Creative Commons Attribution-ShareAlike 4.0 International License
This book is a translation into English of Aprende Test Driven Development which was originally written in Spanish

Price

Pick Your Price...

Minimum price

$15.99

$29.99

You pay

$29.99

Authors earn

$23.99
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 2)

2
The author will earn $24.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Authors

Fran Iglesias

Soy un desarrollador backend que trabaja sobre todo con PHP, aunque no dejo de explorar y probar otros lenguajes. Me interesan mucho las buenas prácticas, especialmente el testing y el test/behavior driven development.

Óscar Iglesias González

¡Hola! Soy un practicante de ciencia de datos y desarrollador, interesado en buenas prácticas y código limpio, especialmente en el contexto del machine learning. Me apasionan aprender y compartir lo aprendido. :)

Contents

Table of Contents

Prologue

  1. How to use this book
  2. Disclaimer
  3. Basic TDD concepts

What is TDD and why should I care about it?

  1. The Test Driven Development methodology
  2. What is not Test Driven Development
  3. Benefits
  4. References

Basic concepts

  1. Test
  2. Types of tests
  3. Test Case
  4. Test Suite
  5. Production code
  6. Software unit
  7. Subject under test
  8. Refactoring

Coding-dojo y katas

  1. Kata
  2. Coding-dojo
  3. Advice for completing the kata individually
  4. How to introduce TDD in development teams
  5. Kata repositories
  6. References
  7. Classic TDD

The laws of TDD

  1. The laws in detail
  2. The second test and the three laws
  3. Violations of the three laws and their consequences
  4. What does it mean if a test passes just after writing it?
  5. The red-green-refactor cycle
  6. References

Fizz Buzz

  1. Understanding the laws and cycles of TDD
  2. History
  3. Problem statement
  4. Hints to solve it
  5. Links of interest about the FizzBuzz kata

Solving the Fizz Buzz kata

  1. Statement of the kata
  2. Language and focus
  3. Define the class
  4. Define the generate method
  5. Define a behavior for generate
  6. Generate a list of numbers
  7. We keep generating numbers
  8. The test that doesn’t fail
  9. Learning to say “Fizz”
  10. Saying “Fizz” at the right time
  11. Learning to say “Buzz”
  12. Saying “Buzz” at the right time
  13. Learning to say “FizzBuzz”
  14. Saying “FizzBuzz” at the right time
  15. Wrapping up
  16. What have we learned in this kata

Selection of examples and finalization criteria

  1. Checklist driven testing
  2. Example selection
  3. Using many examples to generalize an algorithm
  4. In search of the wrong abstraction
  5. The correct abstraction

Evolution of the behavior through tests

  1. Constructing the public interface of a test driven class
  2. Drive the development of a behavior through examples
  3. References

Prime Factors

  1. Introduction
  2. History
  3. Problem statement
  4. Hints to solve it
  5. Links of interest about the Prime Factors kata

Solving the Prime Factors kaka

  1. Statement of the kata
  2. Language and approach
  3. Define the function
  4. Define the function’s signature
  5. Obtaining more imformation about the problem
  6. Introducing a test that doesn’t fail
  7. Questioning our algorithm
  8. Discovering the multiples of 2
  9. Introducing more factors
  10. New divisors
  11. The shortest path isn’t always the fastest
  12. Introducing new factors, second try
  13. More than two factors
  14. Do we have any criteria to select new examples?
  15. What have we learned in this kata

The choice of the first test

  1. In search of the simplest test that can fail
  2. The happiness of the paths

NIF

  1. Start with the sad paths and postpone the solutions
  2. History
  3. Problem statement
  4. Hints to solve it
  5. Links of interest about the kata

Solving the NIF kata

  1. Statement of the kata
  2. Language and focus
  3. Create the constructor function
  4. Implement the first validation
  5. A test to rule them all
  6. Complete the validation of the length and start examining the structure
  7. The not very clean way of changing the test and production code a the same time
  8. Unify the string length validation
  9. Moving forward with the structure
  10. Invert the conditional
  11. The end of the structure
  12. Compacting the algorithm
  13. Finishing the structural validation
  14. Compacting the validation
  15. Let’s look on the bright side
  16. Changing the public interface
  17. NOW it’s time
  18. Moving forward with the algorithm
  19. More refactoring
  20. Validating more control letters
  21. A refactoring, for even more simplicity
  22. NIE support
  23. What have we learned in this kata
  24. References

The refactoring phase

  1. The function of refactoring in TDD
  2. Which refactorings to do
  3. Refactoring limits
  4. When is the right moment to refactor

Bowling game

  1. The refactoring phase
  2. History
  3. Problem statement
  4. Hints to solve it
  5. Links of interest about the Bowling Game kata

Solving the Bowling Game kata

  1. Statement of the kata
  2. Language and approach
  3. Starting the game
  4. Let’s throw the ball
  5. Time to refactor
  6. Counting the points
  7. The world’s worst thrower
  8. Organizing the code
  9. Teaching our game to count
  10. A step back to reach further
  11. Recovering a cancelled test
  12. Getting more comfortable
  13. How to handle a spare
  14. Introducing the concept of frame
  15. Continue handling spare
  16. Removing magic numbers and other refactorings
  17. Strike!
  18. Reorganizing the game knowledge
  19. The world’s best player
  20. What have we learned in this kata

Greetings

  1. A functional kata to rule them all
  2. History
  3. Problem statement
  4. Hints to solve it
  5. Links of interest about the Greetings kata

Solving the Greetings kata

  1. Statement of the kata
  2. Language and approach
  3. Basic greeting
  4. Generic greeting
  5. Use the parameter
  6. Back to the generic greeting
  7. Answering with a yell
  8. Be able to greet two people
  9. Getting ready for several names
  10. A refactoring before proceeding
  11. Reintroducing a test
  12. Handle an indeterminate amount of numbers
  13. Shout to the shouters, but only to them
  14. Separate names that contain commas
  15. Escaping commas
  16. What have we learned in this kata
  17. Outside-in TDD

TDD approaches

  1. Classic TDD or Detroit School
  2. Outside-in, London School or mockist
  3. Behavior Driven Development
  4. So, what approach should we follow? And how do we learn TDD under the light of these approaches?
  5. References

To-do list project

  1. Design

Mockist outside-in

  1. Development
  2. Designing the acceptance test
  3. First unit test
  4. Back to the acceptance cycle
  5. New visit to the acceptance test
  6. Finishing the first user story
  7. Last steps
  8. What have we learned in this kata

Classic outside-in TDD

  1. Posing the problem
  2. Extraction of the use case
  3. Implementing a repository
  4. Obtaining the to-do list
  5. Mark a task as completed
  6. What have we learned in this kata
  7. TDD in real life

Task list, outside-in TDD sliced in user stories

  1. Adding task to a list
  2. Designing in red
  3. Returning to the acceptance test
  4. New cycle
  5. See the tasks on the list
  6. Checking completed tasks
  7. Next steps

Fixing bugs with TDD

  1. To-do list bugs
  2. Invalid payload
  3. Invalid business values
  4. Guaranteeing business rules
  5. Not found tasks
  6. Solving defects

Adding new features

  1. New user story
  2. Complete the story
  3. Epilogue

TDD and quality of life (yours)

  1. Knowledge in the world, knowledge in the head
  2. The capacity of our working memory
  3. A day in the life
  4. A final piece of advice

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub