Fit and Fitnesse
In XP (Extreme Programming) as in other forms of development, there are different types of tests written. Unit Tests are written before the code it exercises. Unit tests are written by developers. In true Test Driven Development you don't write any code without a failing unit test and you don't write code to tackle any other tasks until you have gotten your unit tests to pass. In the xUnit family this is the green bar.
A Unit test might do something like this: create a new Calculator object and check that when the Calculator adds 4 and 6 it gets 10. This won't even compile until you create a Calculator class that has an appropriately named method with the right signature. You then tweak the add method to return the sum of 4 and 6. For Java developers, JUnit is a popular framework for writing and running unit tests. It has been integrated into IDEs such as Eclipse, JBuilder, and IDEA. There are other solutions but JUnit is the current favorite.
Acceptance tests are a very different sort of test. The first distinction is that they are written by customers. An acceptance test is tied to a user story. It is how the customer tells the developer -- when your application makes these tests pass then I will agree that this story has been completed to my satisfaction. Typically, these tests are not running at 100%. In fact, the code that implements the acceptance tests might not be written for a while.
Running this sort of test has been difficult. Ward Cunningham's Fit framework allows the customer to write tests in language that they understand -- spreadsheet type of tables. The developers then write a little bit of code to allow the tests to call into their code and acceptance tests can be automated so that the customers or the developers can run them whenever they want.
The newest piece of the puzzle is Fitnesse . Fitnesse is a small application that allows you to host Wikis and sub-wikis that contain acceptance tests that can be easily run remotely. Fitnesse requires Java 1.4 because it uses some of the regular expression library for parsing. It is easy to set up and run. Thanks to "Uncle Bob" Martin and friends for Fitnesse.
Daniel H. Steinberg is the editor for the new series of Mac Developer titles for the Pragmatic Programmers. He writes feature articles for Apple's ADC web site and is a regular contributor to Mac Devcenter. He has presented at Apple's Worldwide Developer Conference, MacWorld, MacHack and other Mac developer conferences.
Comments on this weblog
Return to weblogs.oreilly.com.