What Is Your Unit Testing Philosophy?

room: Conference D, M — time: Thursday 14:00-15:30
Average Rating: -

Do you have a preferred way to write unit tests?

Could you describe it to your pairing partner? Could you describe it to your team? Could you intentionally adjust it to suit a particular testing context?

If your team does not have a shared, explicit unit testing philosophy you’re not getting full value from your testing efforts.

In this tutorial you will learn a simple, powerful technique to describe your unit test philosophy.

Process/Mechanics

DESCRIPTION

In the first part of the tutorial you will learn a simple, powerful technique to describe your unit test philosophy. You will learn how to use the same simple technique to adjust your testing philosophy according to context.

In the second part of the tutorial you will see how a pair applies an explicit and shared testing philosophy during a programming episode. You will be able to jump in anytime during the programming episode by asking questions, making solution suggestions, or even typing in some code. Watch and you will learn useful pairing techniques such as: Test Ping-Pong, Interaction Testing using jMock, Test-First Programming, and Navigator Keeps A List.

Our simple, powerful technique for creating and describing a unit testing philosophy is to imagine a mixing desk with sliders that let you adjust the “mix” on these six “channels”:

  • Test First or Test After?
  • Tests or Examples?
  • Test-by-Test or All-At-Once?
  • Outside-In or Inside-Out?
  • State or Behavior Verification?
  • Fixture Design Up Front or Test-by-Test?

In our experience, this metaphor makes it easier to see that we don’t need to make either-or choices. Instead, anyone can create a nuanced, context sensitive unit testing philosophy by first understanding what each channel does and by then adjusting each of the sliders. The metaphor also makes it very clear that the resulting unit testing philosophy is adjustable.

Note: The choice of channels and their definition is from xUnit Patterns by Gerard Meszaros.

PROCESS/MECHANICS

During the first 30 minutes we present our metaphor for creating a unit test philosophy and share stories that illustrate the importance of a shared, explicit unit testing philosophy for team alignment and performance.

For the remaining 60 minutes:

  1. We describe our own unit testing philosophy.
  2. Introduce a simple but realistic programming task.
  3. Complete a programming episode as a pair.

We expect these 60 minutes to very interactive. We have presented this tutorial twice. At our last presentation the audience was very engaged: asking lots of questions, demanding clarifications, making solution suggestions, and sharing their own stories.