Automated Testing Clinic: Testing with a Purpose
Summary
There are two questions worth asking oneself over and over while creating automated acceptance tests.
- What is the purpose of this test?
- Does the test express this purpose as clearly as possible?
This clinic uses exercises and examples to reinforce the good habit of writing tests with a clear purpose. Our focus is on favoring declarative style over procedural (Testing the business rule rather than the user actions/steps).
The key learning -- writing purposeful tests -- is tool-independent; however, our exercises are in FitNesse (Java), so this clinic will also provide attendees a way to learn and practice FitNesse.
Objectives
- Learn how to write more understandable tests.
- Create stronger, more useful tests with less effort.
- Build test suites that are valuable to non-testers.
Gain experience writing and running tests in FitNesse (Java).
Audience
- Developers and testers interested in creating automated acceptance tests.
- Bring laptop set up with a Java development environment. (Or perhaps the instructors can provide a USB with complete setup for this clinic)
Exercises
Our teaching style uses step-by-step, guided exercises in the first section; more free-form and challenge in the second section.
First session Introduction to Purposeful Testing:
- Participants rate a bunch of example tests for understandability; gather all ratings, show tests in order of their rating, discuss what makes tests readable or unreadable.
- Creating test objectives from requirements: Instructors provide a "bad" example to contrast with good examples created by participants; discuss.
Introduction to FitNesse: ColumnFixture, RowFixture, ActionFixture.
- Removing unnecessary detail: Turning a messy, unreadable test into a clearly understandable test.
- Declarative vs. procedural style: refactoring a set of procedural tests into a single declarative test.
- Demo: One of the instructors has, during the session, taken many of the participants' test objectives from the test objective exercise and created a working, declarative style test. This demo should encourage them how easy creating tests can be.
Second session Practicing Purposeful Testing:
- Show one example test at a time; taking that example as a starting point, participants brainstorm for more test cases. Discuss which tests made it easier for them to think of more diverse test cases.
- Soup to nuts: Teams write tests for a sample application we provide. Instructors guide and answer questions.
- Test coverage is measured for each team, and discussed.
- Teams swap tests. The new owners of the tests review the tests and identify their purpose. Spokesperson from each team presents findings; discuss.
About the instructors
Kay has 7 years experience leading automated testing efforts and has taught corporate training classes in FitNesse. Christian is the author of the open source acceptance testing framework Jameleon and has mentored teams in unit and acceptance testing for 7 years. Both instructors presented tutorials at Agile 2007 and have been active in the Agile community since 2001.
