The test framework of Grail42 is a thread safe, thread aware, multi-platform C++ test framework. It is thread safe in that its verification macros are safe to use in concurrently executing threads and any error messages from a failed verification will be correctly serialized to the standard output even when errors occur on multiple threads. The test framework is thread aware as it allows a test to be defined in multiple parts that will each be automatically executed on a separate thread by the framework. It is multi-platform as it has been tested on Windows 7 64-bit, Android 2.2, and Chrome Native Client 23 64-bit and compiled with Visual Studio 2010, gcc 4.4, and gcc 4.6.
Grail42 also includes a unit test project wizard / template and instructions on its use can be found in that project’s readme.
A simple example of usage follows:
#include <g42core/test/test.hpp> #include <g42core/test/short_defines.hpp> #include <g42core/test/main.hpp> BEGIN_TESTS() // single threaded test DEFINE_TEST() { VERIFY(false); } // two threaded test DEFINE_TEST_PART_MT("t1") { VERIFY(false); } DEFINE_TEST_PART_MT("t1") { VERIFY(false); } END_TESTS() int wmain(int, wchar_t* []) { return G42CORE_TEST_RUN_TESTS(); }
and the execution of the above code results in the output:
*** Tests started *** unit_test000.cpp(20): false unit_test000.cpp(26): false unit_test000.cpp(30): false *** Tests complete: 0 passed, 2 failed, 0 skipped ***
Enjoy!
Pingback: Grail42: test framework done enough for now | Josh Heitzman on Codecrafting