#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:
class UnitTestExample : public UnitTestComponent<UnitTestExample> { MAXON_COMPONENT ();
公共成员函数 |
|
MAXON_METHOD Result < void > | Run () |
MAXON_METHOD Bool | IsCancelled () const |
MAXON_METHOD void | 取消 () |
MAXON_METHOD void | AddResult (const String &testName, Result < void > state) |
MAXON_METHOD void | AddTimingResult (const String &testName, Result < void > state, TimeValue duration) |
MAXON_METHOD Bool | ReInitializeBuildId (const String &buildId, const UniversalDateTime &dateTime) |
私有成员函数 |
|
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:
Running unit test 9/16: net.maxon.unittest.example Unittest "net.maxon.unittest.example" OK : Test1[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_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 | ||
) |