[vtk-developers] Unit test experience

Bill Lorensen bill.lorensen at gmail.com
Mon May 9 14:19:52 EDT 2016


Folks,

I occasionally decide to improve coverage of a class or set of related
classes by writing a unit test. The unit test tries to exercise and
validate (when possible) all of a class' methods.

Virtually, every time I write a unit test I discover defects. Some are
trivial, others are significant.

For example, I noticed that vtkGenericGeometryFilter only had about
75% coverage. While writing the unit test, I discovered that one of
the methods ExtentClippingOn() was not working (it never worked!).

The merge request
https://gitlab.kitware.com/vtk/vtk/merge_requests/1484
covers 98% of the class.

The class and header have 256 lines of code. The unit test has about
300 lines of code. Where possible, the unit test checks the results of
the methods. If also checks error conditions.

One of these days, I'll write a wiki page describing my approach to
vtk unit testing.

Bill


More information about the vtk-developers mailing list