The unit test framework that is used in OpenDCS is based off of the work done by the developers of libgee, specifically the TestCase class that extends what’s available in GTest which is included in GLib.

Building Tests

To build the unit test applications as part of OpenDCS the argument to enable building must be added when generating the output of autotools.

$ ./autogen.sh --enable-tests

Executing Tests

The tests have been broken into different sections in case there is the future need to provide conditional builds of some of the sections, eg. omitting support for a GUI.

Running all of the tests available for one of the categories of tests is done using the application for that section. Each uses gtester but can be invoked directly, for example to test the core components:

tests/test-dcs-core --verbose

Which results in:

GTest: random seed: R02S969cd3dff33efbc82f8a926b428a96a5
(MSG: Execute core unit tests)
GTest: run: /DcsObject/[DcsObject] Test equivalency
GTest: result: OK
GTest: run: /DcsObject/[DcsObject] Test comparison
GTest: result: OK

Or using gtester directly:

$ gtester --verbose tests/test-dcs-core
TEST: tests/test-dcs-core... (pid=24910)
  /DcsObject/[DcsObject] Test equivalency:                             OK
  /DcsObject/[DcsObject] Test comparison:                              OK
PASS: tests/test-dcs-core

Individual test cases can also be specified using a path argument such as:

$ gtester --verbose -p /DcsObject tests/test-dcs-core

Which at this time results in the same output as above.