UnitTestInterface Class Reference 系统

#include <unittest.h>

Inheritance diagram for UnitTestInterface:

详细描述

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 ();
public : Result<void> Run () { Bool res; // Do some operations here. res = (5 == 5); // Add the result to the database. self .AddResult( "Test 1" _s, res ? OK : UnitTestError( MAXON_SOURCE_LOCATION , "5 == 5" _s)); // Do more Tests. return OK ; } }; MAXON_COMPONENT_CLASS_REGISTER (UnitTestExample, UnitTestClasses, "net.maxon.unittest.example" );

公共成员函数

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")

成员函数文档编制

◆  MAXON_INTERFACE()

MAXON_INTERFACE ( UnitTestInterface   ,
MAXON_REFERENCE_NORMAL   ,
"net.maxon.interface.unittest"   
)
private

◆  Run()

MAXON_METHOD Result <void> Run ( )

This functions needs to be overridden with the implementation of the test code (see example).

返回
OK on success. The result has no effect on other unit tests. If an error is returned it will be output (and added to the SQL database if enabled).

◆  IsCancelled()

MAXON_METHOD Bool IsCancelled ( ) const

Checks if the Test has been cancelled from outside.

返回
In case of true the test should exit immediately.

◆  Cancel()

MAXON_METHOD void Cancel ( )

Cancel all UnitTestClasses.

◆  AddResult()

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.

◆  AddTimingResult()

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.

◆  ReInitializeBuildId()

MAXON_METHOD Bool ReInitializeBuildId ( const String buildId ,
const UniversalDateTime dateTime  
)
maxon::UnitTestInterface::Run
MAXON_METHOD Result< void > Run()
MAXON_COMPONENT
#define MAXON_COMPONENT(KIND,...)
定义: objectbase.h:2036
maxon::OK
return OK
定义: apibase.h:2532
MAXON_COMPONENT_CLASS_REGISTER
#define MAXON_COMPONENT_CLASS_REGISTER(C,...)
定义: objectbase.h:2233
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53