Writing Tests for Dune

Inspired by the principles of Extreme Programming every developer is encouraged to write test cases whenever he encounters a bug, or even better write a test before adding new functionality to Dune

Integrating Tests into the build system

The automake build system offers an easy way to add tests. We decided to put all tests belonging to one module into a subdirectory test (i.e. all test for dune/common belong into dune/commom/test). In this directory one lists the tests in the Makefile.am. Automake offers two classes of tests, those that must run (TESTS) and does that must not run (XFAIL_TESTS):

...

TESTS = mustrun
XFAIL_TESTS = mustfail

mustrun_SOURCES = mustrun.cc
mustfail_SOURCES = mustfail.cc

...

Writing compile-time Tests

As described by Bjarne Stroustrup himself ( C++ Style and Technique FAQ), there are ways to write compile time tests in C++ that ensure that a certain part of the code is compiled, but will never be executed. This kind of checks is heavily used in the tests of the grid interface in dune/grid/test/gridcheck.cc.

Currently the build system does not support compile time test that must fail.

Writing Runtime Tests

We currently don't use a special test framework for runtime tests.