Test-Driven Development First Steps
Topic: Software Development
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.
Prior experience with Python
- Watch Test Driven Development, Refactoring and Pair Programming (video course)
- Read The Art of Unit Testing, 2nd Edition (book)
- Read Test Driven Development: By Example (book)
- Read Test-Driven Java Development (book)
- Read Test-Driven Python Development (book)
About your instructor
Julian Zucker is a machine learning engineer at Klaviyo, where he uses functional programming concepts to productionize ML models. Previously, he developed an open source time series database at Pivotal and created large-scale data processing systems for analytics at PayPal. He’s the lead maintainer of an open source library that implements social choice methods, built using immutable data structures.
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
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()
- Exercise: Write a test for is_empty() [the true case]
- Implement is_empty()
- Exercise: Write another test [the false case] and fix implementation
- 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
- Exercise: Write a test for length() and implementation
- Exercise: Discuss what to refactor, then refactor
- Will change internal data structure
- Refactor is_empty() to use length()
- 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