EasyTest++
EasyTest++ is a lightweight and easy to use C++ unit testing framework released under the MIT license.
Why to use it ?
- lightweight C++11 unit testing framework
- xUnit architecture with assertions and fixtures
- single static library, no external dependencies (except
pthread
under Linux) - auto-registration of test suites and test cases
- measures execution times of all test cases and test suites
- integrated test runner with parallel execution of test suites
- multiple internationalized output formats: log, TAP, JavaScript and JSON
- easily integrated with custom test harnesses or results formatters in HTML
- neither relies on C++ exceptions nor RTTI
- intercepts uncaught C++ exceptions and runtime errors (floating-point exceptions, illegal instructions, divisions by zero, memory access violation, etc...)
- available on Linux and Windows for 32 and 64 bits architectures
How to use it ?
Download the latest release and extract it to a folder named EasyTest++.
Write your first unit test suite: MyTestSuite.cpp.
#include <easyTest.h>
TEST_SUITE(MyTestSuite)
{
TEST_CASE(addition);
TEST_CASE(division);
};
TEST_IMPL(MyTestSuite, addition)
{
ASSERT_EQUAL(1 + 1, 2);
return true;
}
TEST_IMPL(MyTestSuite, division)
{
ASSERT_ALMOST_EQUAL(1.0 / 3.0, 0.3333, 0.0001);
TRACE("no issue with doubles");
ASSERT_ALMOST_EQUAL(1.f / 3.f, 0.333f, 0.001f);
TRACE("no issue with floats");
return true;
}
Build the test runner and you're ready!
$ g++ -std=c++11 -I./EasyTest++/include -o Test_MyTestSuite MyTestSuite.cpp -pthread -L./EasyTest++/lib -lEasyTest++_linux64
$ ./Test_MyTestSuite -sv
Want to know more ?
Just go to the GitHub project page.
You will find detailed information about how to build EasyTest++ yourself and how to use it.
If you have any question, any issue or great ideas to make it better, please post an issue on the project page.