Unit test framework

Colin Girling edited this page May 2, 2016 · 19 revisions

Overview

Welcome to cppocl/test which is where the C++ unit test framework can be found. To use this only requires including Test.hpp for each source code file that has unit tests, and TestClass.cpp needs to be added to the makefile or project file.

This framework is tested on a C++ 98 and C++ 11 compiler, so should be usable by older projects or embedded Linux systems using various C++ cross compilers.

This seems to be fairly stable, and has been used by myself for many months now, but I am still continuing with improvements and writing unit tests to test the unit test framework.

This framework is designed to test functions, member functions and also be able to write performance tests which can then be examined in the report generated by the framework to stdio.

Please let me know if you find and bugs and I will fix them. I will also consider any new feature requests, but I am not looking for contributors at the moment.

There is also a document that explains the features of the framework in the test folder.

Features

  • Perform checks such as true, false, <, >, ==, !=, etc. on general tests, functions and member functions.
  • Test performance of general tests, functions or member functions.
  • Check if exception is or is not thrown
  • Detect test failures from main function
  • Logging to stdout and stderr
  • Header only library with only Test.hpp needing to be included
  • Written to be easy to write tests
  • Library can be stored in any folder as files are relative to Test.hpp
  • Builds on Linux and Windows 32/64 bit. Tested with Cygwin, gcc, MS Visual C++ 2005/2015.
  • Compliant with C++ 98 and C++ 11
  • Custom logging

Wish list

This is a list of features that will be added to the unit test framework:

  • Break on error
  • Output failures in IDE friendly format
  • More...

Examples

See - https://github.com/cppocl/cppocl/blob/master/test/Examples.cpp

Project Source Code

Code can be found here: https://github.com/cppocl/cppocl/tree/master/test

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.