#include <unittest.h>
Class for Unit tests. All available interfaces and implementations should get a unit test to verify the correct function of the interface. A unit test should check the positive and negative return values. E.g. also if giving wrong arguments to functions return the expected error code. There are 3 different categories of tests right now. They can be registered with MAXON_COMPONENT_CLASS_REGISTER.
Here is an example how this class should be used:
Public Member Functions | |
MAXON_METHOD Result< void > | Run () |
MAXON_METHOD Bool | IsCancelled () const |
MAXON_METHOD void | Cancel () |
MAXON_METHOD void | AddResult (const String &testName, Result< void > state) |
MAXON_FUNCTION void | AddResultBool (const String &testName, Bool state) |
MAXON_METHOD void | AddTimingResult (const String &testName, Result< void > state, TimeValue duration) |
MAXON_METHOD Bool | ReInitializeBuildId (const String &buildId, const UniversalDateTime &dateTime) |
Private Member Functions | |
MAXON_INTERFACE (UnitTestInterface, MAXON_REFERENCE_NORMAL, "net.maxon.interface.unittest") | |
|
private |
MAXON_METHOD Result<void> Run | ( | ) |
This functions needs to be overridden with the implementation of the test code (see example).
MAXON_METHOD Bool IsCancelled | ( | ) | const |
Checks if the Test has been cancelled from outside.
MAXON_METHOD void Cancel | ( | ) |
Cancel all UnitTestClasses.
MAXON_METHOD void AddResult | ( | const String & | testName, |
Result< void > | state | ||
) |
Outputs the result to the console in a standard format. This format can be analyzed by tools. The output may be added to an SQL database. The example above prints these lines:
[in] | testName | A unique name within your test class. This is the identifier for later comparisons with previous builds. |
[in] | state | The result of the test. |
MAXON_FUNCTION void AddResultBool | ( | const String & | testName, |
Bool | state | ||
) |
Outputs the result to the console in a standard format. This is similar to AddResult, but you have to provide just a Bool value where false indicates a failure.
[in] | testName | A unique name within your test class. This is the identifier for later comparisons with previous builds. |
[in] | state | The result of the test: true means success, false means failure. |
MAXON_METHOD void AddTimingResult | ( | const String & | testName, |
Result< void > | state, | ||
TimeValue | duration | ||
) |
Outputs the result with timing to the console in a standard format. Same AddResult() but with timing added.
[in] | testName | A unique name within your test class. This is the identifier for later comparisons with previous builds. |
[in] | state | The result of the test. |
[in] | duration | Duration of the test. |
MAXON_METHOD Bool ReInitializeBuildId | ( | const String & | buildId, |
const UniversalDateTime & | dateTime | ||
) |