Open-Transactions/Open-Transactions — pull request #139 by murrekatt (2014-05-06 12:15:06+00:00)
Title: Starting-point for unit tests

Added a simple initial unit test to get a start with the unit tests structure.

Unit tests must be put under the tests subdirectory under root using the exactly same directory structure as in src. This is important. Take a look at what is there now.

The unit tests should be grouped logically per library or sub-part that makes sense as we move forward. At the moment I have only included otlib and a test driver for that. Further, what is important is how we name things:

Unit tests are written per class/struct or similar and named Test_.cpp and included as part of a test driver called unittests_ for e.g. a library. In this case I have used OTData in otlib and thus have Test_OTData.cpp and a test driver called unittests_otlib.

To run the unit tests we can simply run: make check

Travis now also runs the unit tests for all builds.

Writing proper unit tests is important and they must be e.g. independent, deterministic, short, fast, maintained and in use to have any value. Other types of testing like functional testing is also important, but this must stay separate from unit testing.

I'm happy to teach whoever want to learn about this - just let me know. I'll also add soon something on the wiki about writing good unit tests.