Agile Event Session

Unit Tests as Specifications

This video content is for Agile Alliance members only

If you’re already an active member, please log in now.

To view this content, and gain access to many more valuable resources, conference discounts, and invitations to exclusive networking and learning events, please consider becoming an Agile Alliance member.

Abstract/Description

Test-driven development is a core practice of Extreme Programming (XP) and the “secret sauce” for some teams, enabling them to rapidly build quality code. But for other teams it’s an impediment that keeps them from refactoring code and increases their technical debt. TDD is supposed to help us refactor code safely but we often find that when we refactor our code we also have to change our tests, and what was supposed to add safety becomes a burden, requiring time and effort to keep tests up to date.

Writing good unit tests is a critical skill that developers need to master in order to get the most benefit from test-driven development. Tests must be unique, written at the right level of abstraction, and implementation-independent in order to be most valuable. When we understand how to use tests to articulate the behaviors we want to create, we can recognize the correct number and kind of tests needed to describe the behavior we want to build, putting every member of a team on the same page and building the right kind and number of tests that drive the creation of any behavior in the system. Our tests become a form of living specifications.

In this session, we’ll cover effective techniques for doing TDD that support building useful tests and quality code. You’ll learn how to instrument unit tests so they’re more readable and flexible. Instrumentation helps make a test’s intention clear and removes magic numbers from code.

You’ll also learn how to approach TDD in a way that yields the right number and kind of tests that allow you to refactor code later without breaking it. Working through a few code examples, we’ll see how many assertions are required to specify a linear range, exceptions, and other boundary conditions. We’ll look at how to write tests that don’t need to be changed when code is refactored while still keeping test coverage high.

If you’ve struggled to apply TDD on a project, or are just not sure how to start, then this session is for you.

Additional Resources

Speaker(s) may be willing to present this session at local group meetings and other events.

deliver:Agile 2018
Slides, Video
Practicing

More Agile Event Session Videos

FP vs. OOP: Beyond the Bikeshed
In object-oriented languages like Ruby, people often say that “everything is an object”—but first-class functions have become standard for object-oriented languages too. C# has had them and other related features for years, and even Java is in the ga…
Testing Without Mocks: A Practical Guide
Are your tests slow or brittle? Do you get a sinking feeling when you need to refactor? Do you worry your unit tests aren't actually testing anything important? If so, you could benefit from exploring a mock-free approach to TDD. This session is a c…
Building Your Team to Last
Hiring and on-boarding new team members is an expensive and risky process. It's crucial to hire people who mesh well with the existing team and get them up to speed in a timely manner. Balancing this while minimizing the initial impact on productivit…
FP vs. OOP: Beyond the Bikeshed
In object-oriented languages like Ruby, people often say that “everything is an object”—but first-class functions have become standard for object-oriented languages too. C# has had them and other related features for years, and even Java is in the ga…
Testing Without Mocks: A Practical Guide
Are your tests slow or brittle? Do you get a sinking feeling when you need to refactor? Do you worry your unit tests aren't actually testing anything important? If so, you could benefit from exploring a mock-free approach to TDD. This session is a c…
Building Your Team to Last
Hiring and on-boarding new team members is an expensive and risky process. It's crucial to hire people who mesh well with the existing team and get them up to speed in a timely manner. Balancing this while minimizing the initial impact on productivit…

Have a comment? Join the conversation

Discover the many benefits of membership

Your membership enables Agile Alliance to offer a wealth of first-rate resources, present renowned international events, support global community groups, and more — all geared toward helping Agile practitioners reach their full potential and deliver innovative, Agile solutions.

IMPORTANT: We have transitioned to a new membership platform. If you have not already done so, you will need to set up an account on the new platform to establish your user profile.

When you see the login screen, choose “Set up Account” and follow the prompts to create your new account. You can choose to log in using your social credentials for either Google or Linkedin (recommended), or you can set up your account using an email address.

Not yet a member? Sign up now