|
Carpenter Engine
A C++ game engine with a build once run anywhere solution
|
A Unit tester used to run C++ unit tests. More...
#include <Testing.hpp>
Public Member Functions | |
| void | addTest (std::string name, std::function< void()> test) |
| void | runTests () |
| void | DebugLog (std::string message) |
| void | DebugError (std::string message) |
| void | Assert (bool condition, std::string message) |
| void | PrintLogs () |
| unsigned int | getTestCount () |
| unsigned int | getPassedTestCount () |
Static Public Member Functions | |
| static TestRunner & | getInstance (std::string name="Test") |
A Unit tester used to run C++ unit tests.
The goal of this class is to run C++ unit tests for WebAssembly. This class is a singleton that is accessed with Testing::TestRunner::getInstance() and you add tests with Testing::TestRunner::addTest(). These tests get processed and compiled to WASM before being run via JavaScript and running table test. There are extern functions defined in the Testing.cpp file that you can access to run tests.
Testing::TestRunner::getInstance() and should be assigned to references of the class.| void Testing::TestRunner::addTest | ( | std::string | name, |
| std::function< void()> | test | ||
| ) |
Adds a test to the test runner
| name | The name of the test |
| test | The test function |
| void Testing::TestRunner::Assert | ( | bool | condition, |
| std::string | message | ||
| ) |
Asserts that the condition is true. If the condition is false, an error message will be printed in the logs via TestRunner::DebugError()
| condition | The condition to assert |
| message | The message to print |
| void Testing::TestRunner::DebugError | ( | std::string | message | ) |
Logs an error message to the test being run
| message | The message to print |
| void Testing::TestRunner::DebugLog | ( | std::string | message | ) |
Logs a message to the test being run inside Use this instead of std::cout to log messages inside tests
| message | The message to print |
|
static |
Returns an instance of the test runner
Testing::TestRunner runner = Testing::TestRunner::getInstance();Testing::TestRunner& runner = Testing::TestRunner::getInstance(); | unsigned int Testing::TestRunner::getPassedTestCount | ( | ) |
Returns the number of tests that have passed
| unsigned int Testing::TestRunner::getTestCount | ( | ) |
Returns the number of tests that have been run
| void Testing::TestRunner::PrintLogs | ( | ) |
Prints and dequeues all the logs in the logs vector. This is called by runTests() after each test
| void Testing::TestRunner::runTests | ( | ) |
Runs all the tests, processes, and outputs the results. This is called by the table test command so it is not meant to be called manually.