Sunday, June 3, 2007

A language for test

Writing tests is hard
=====================


Writing unit tests is hard. Often harder than writing the application. Our current choice of languages does not help much. General purpose programming languages were designed to solve application development problems not necessarily help us test the application under development. Virtual machines such as Sun's JVM and Microsoft's .NET runtime provide basic support by exposing the code meta-model so that test frameworks can be developed. To my knowledge 'test frameworks' have not been made high priority aspects of current language design.

Initiatives like [Behaviour-Driven Development](http://behaviour-driven.org) (BDD) add new dimensions to verifying the behaviour of an application. BDD uses a constrained analysis language to define the intended behaviour for the domain model. This behaviour statement is then used to generate executable code that it then run against the application.

BDD is an important step but is by its nature a confined to particular types of application (those with a domain model).

So what could a test language look like?
----------------------------------------

test-case: test case name
given ::=
BankAccount (Balance => 12.50, OverDraftLimit => 100)
when

verify that ::=
BankAccount

No comments: