O'Reilly logo
live online training icon Live Online training

Test-Driven Development First Steps

enter image description here

Julian Zucker

Test-driven development is a software development methodology that has been empirically shown to improve code quality with no change in development speed. Join Julian Zucker for a hands-on introduction to test-driven development. By writing code and tests, you will learn how to develop software using the test-driven development paradigm. After performing a refactor on your code, you will see first-hand how test-driven development can make your life easier.

What you'll learn-and how you can apply it

By the end of this live, hands-on, online course, you’ll understand:

  • The benefits of test-driven development.
  • How writing tests speeds up writing code.
  • How writing tests leads to writing better code.

And you’ll be able to:

  • Use test-driven development to guide your programming efforts.
  • Convince others (for example, your manager!) of the value of test-driven development.
  • Writer better code, with higher test coverage, and develop faster than you used to.

This training course is for you because...

  • You’re a software engineer who wants to write code faster.
  • You’re a software engineer who wants to write code with fewer bugs.
  • You’re a software engineer who wants to make their code easier to refactor.

Prerequisites

Prior experience with Python

Recommended follow-up:

About your instructor

  • Julian Zucker is a software engineer at Pivotal, where he works on an open source protocol for monitoring cloud computing workloads. Previously, he was a business intelligence engineer at PayPal creating large-scale data processing systems for analytics. He’s a core developer on Evvo, an open source distributed evolutionary computing framework. He’s published work on simulations of the evolution of intergroup social interactions and enabled the exploration of ideas that were never before able to be simulated by parallelizing the simulations.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

What is TDD (10 minutes)

  • Chat: What is your current development methodology?
  • Presentation: What is TDD?
    • High-level overview, example of some code snippets
    • Ping-pong, red-green-refactor
    • Literature reviews about developer productivity/code quality gains
  • Presentation: What is not TDD?
    • Common misconceptions
  • Q&A

Hands-on TDD (95 minutes)

  • Presentation: Testing with assertions and py.test
  • Presentation: What is a range?
  • Do you have the Jupyter notebook?
  • Exercise: Implement range()
    • is_empty()
    • Exercise: Write a test for is_empty() [the true case]
    • Implement is_empty()
    • Exercise: Write another test [the false case] and fix implementation
  • Break
  • contains()
    • Exercise: Write a test for contains() [the false case] and implementation
    • Exercise: Write a test for contains() [the true case] and implementation
    • Exercise: Write a test for contains() [the edge cases] and implementation
  • length()
    • Exercise: Write a test for length() and implementation
  • Refactor
    • Exercise: Discuss what to refactor, then refactor
    • Will change internal data structure
    • Refactor is_empty() to use length()
  • intersects()
    • Exercise: Write tests and implementation
    • Recap about how it felt
  • iter() (time permitting)

Recap (15 minutes)

  • Presentation: Benefits of TDD in this toy example
  • Presentation: Benefits of TDD in larger examples, bigger refactors
  • Q&A