Question

I'm writing a software library for some numerical computations. I'd like to use Boost Unit Test framework to write a hierarchical unit-test covering not only basic input/output behavior of functions but also the higher functionality, e.g. correct results to some test problems etc.

However, I'm afraid, that I'll get lost in a complexity of tests. Is there any standard way to list them? Like some unit-test diagram?

Was it helpful?

Solution

I don't think there is a "standard diagram", but there are naming conventions for unit tests around, like this one or this one.

I would recommend first and foremost to have a good structure and documentation for the library. Then, one should establish a rigid naming convention for the tests so it stays easy to see which test belongs to which part of the library. In general, the structure of unit tests should follow the structure of the subject under test. For example, for every class or module Foo, the related tests could be in a class TestFoo or FooTest. For a more sophisticated convention, follow the links above.

If you go that route, the structure of your lib imposes enough structure on your tests that you do not need some extra "list" or "diagram".

OTHER TIPS

A possible solution is to reduce the complexity of tests. For instance, with property-based testing (eg, ScalaCheck, QuickCheck) a single test could replace several unit tests as special cases. Then the whole testing hierarchy is flattened. Property testing fits maths/numerical applications particularly well, but at a computational cost.

A complementary approach, in line with the OP's hunches, is to use a testing framework amenable to a hierarchy of tests. This goes towards behaviour-driven development (BDD). You could have a high-level function (= BDD "Feature") and low-level supporting functions ( = BDD "Scenarios"). BDD testing tools easily accommodate this hierarchy. Some of them have nice GUIs visually organising, if not diagramming, it. In addition, they can serve as living documentation.

Some BDD references/search terms: "BDD In Action", Dan North, cucumber, serenity tool.

Licensed under: CC-BY-SA with attribution
scroll top