'

Prose + Test Cases = Specifications

Daniel Hoffman, University of Victoria, Canada

Paul Strooper, University of Queensland, Australia

The rise of component-based software development has created a strong need for API documentation. Experience has shown that it is hard to create and maintain precise and readable documentation. Prose documentation can provide a good overview but lacks precision. Formal methods offer precision but the resulting documentation is expensive to write and modify. Worse, few developers have the skill or inclination to read formal documentation.

We present a pragmatic solution to the problem of API documentation. We augment the current prose documentation with test cases, including expected outputs, and use the prose plus the test cases as the documentation. Typically there are one or two simple test cases for each likely question about API behaviour. There are four important benefits to this approach. The documentation is precise, albeit partial. Consistency between code and documentation is guaranteed by running the test cases. Running the test cases will frequently reveal faults. The documentation provides examples, suitable for copying and modification by API users. The readability of the test cases is of paramount importance; communication with API users is their primary purpose.

We present a test script language that supports compact, readable test cases and generation of test drivers, and illustrate the approach with a detailed case study.'