winIDEA SDK
isys::CTestStubController Class Reference

Description

This class wraps test case stubs, which are created, used, and destroyed by IControlTest class.

Stubs may have lifetime different than single test case, for example they may be used by several test cases.

Stub replaces function called by function under test. Since no code instrumentation is allowed, only breakpoint is set at the given function. When the function is called, the test case execution stops, and then the test framework can define next actions. Usually it will simulate desired side effects of a stubbed function (for example set return value, local and global variables), and then continue execution of the function under test.

Destructor automatically destroys the stub on the target.

#include <CTestCaseController.h>

Inheritance diagram for isys::CTestStubController:
isys::WrapperBase

Public Types

enum  EStubType {
  E_SCRIPT_STUB , E_RT_USER_STUB ,
  E_RT_EMPTY_STUB
}
 Enumeration for stub types. More...
 

Public Member Functions

void create (IConnectTest::EStubFlags flags, const std::string &stubbedFunctionName)
 Creates stub in winIDEA. More...
 
void createParameter (DWORD parameterIndex, const std::string &parameterName)
 Assigns a name to stub parameter at the given position. More...
 
void createReturnValue (const std::string &retValName)
 Assigns a name to stub return value. More...
 
 CTestStubController (std::shared_ptr< ConnectionMgr > connectionMgr)
 Creates empty controller, call method create() to actually create stub in winIDEA. More...
 
 CTestStubController (std::shared_ptr< ConnectionMgr > connectionMgr, const std::string &stubbedFunctionName)
 Creates function stub on the target. More...
 
DWORD getHandle ()
 Returns handle as used by IConnectTest.
 
std::string getRetValName ()
 Returns return value name.
 
std::string getStubName ()
 Returns stub name.
 
 ~CTestStubController ()
 Destroys also stub on the target.
 

Member Enumeration Documentation

◆ EStubType

Enumeration for stub types.

Enumerator
E_SCRIPT_STUB 

stub is implemented as breakpoint at the start of the

stubbed function. Target stops and program (script) on PC takes control

E_RT_USER_STUB 

user specified function on a target is called instead of the stubbed function

E_RT_EMPTY_STUB 

the stubbed function is not executed, but ths execution immediately

returns to the caller

Constructor & Destructor Documentation

◆ CTestStubController() [1/2]

isys::CTestStubController::CTestStubController ( std::shared_ptr< ConnectionMgr connectionMgr)

Creates empty controller, call method create() to actually create stub in winIDEA.

Use this ctor, when greater flexibility is required for stub creation (for example, when stub breakpoint setting should not be managed by winIDEA (for example, when there are not enough HW BPs)).

Parameters
connectionMgrconnection to winIDEA

◆ CTestStubController() [2/2]

isys::CTestStubController::CTestStubController ( std::shared_ptr< ConnectionMgr connectionMgr,
const std::string &  stubbedFunctionName 
)

Creates function stub on the target.

Parameters
connectionMgrconnection to winIDEA
stubbedFunctionNamename of the function to be stubbed

Member Function Documentation

◆ create()

void isys::CTestStubController::create ( IConnectTest::EStubFlags  flags,
const std::string &  stubbedFunctionName 
)

Creates stub in winIDEA.

Parameters
flagssee IConnectTest::EStubFlags
stubbedFunctionNamename of the function to be stubbed

◆ createParameter()

void isys::CTestStubController::createParameter ( DWORD  parameterIndex,
const std::string &  parameterName 
)

Assigns a name to stub parameter at the given position.

The assigned name may be used in expressions by CTestCaseController::evaluate() and CTestCaseController::modify().

Parameters
parameterIndex0 - based parameter index
parameterNamename assigned to parameter

◆ createReturnValue()

void isys::CTestStubController::createReturnValue ( const std::string &  retValName)

Assigns a name to stub return value.

The assigned name may be used in expressions by CTestCaseController::evaluateExpression() and CTestCaseController::modifyExpression() to define value returned to the function under test.

Parameters
retValNamename assigned to return value