ITestMultiplexer

ITestMultiplexer is a subclass of ITest which tests a number of decision functions.

ITestMultiplexer supports the model of multiple decision functions applied to a single test target. Its purpose is to allow multiple related tests to be implemented in one class. Tests are implemented as member functions. Clients derive new subclasses of ITestMultiplexer containing member functions called decision functions which return boolean success values.

ITestMultiplexer selects one or more decision functions to execute in order to perform the test. The selection of the decision function can be set either programmatically or by parsing the test input arguments. To subclass ITestMultiplexer, clients write the decision functions and override loadDecisions(..).

These decision functions are methods which are analogous to the ITest::test method. They are different in that they return a Boolean result rather than calling ITest::setSuccess. A TRUE return value indicates success. Each decision function has an associated test key. This key is used to select the decision function at run-time.

The key may be changed in a number of ways. There are methods which directly set the key. Alternatively, a client may specify that one or more of the initial input arguments are to be interpreted as a key. These two methods are mutually exclusive; only one or the other is in effect at any time.

One key comes predefined. This is the key "kAllDecisions", which has the effect of running all decision functions and doing a logical AND of the results. If any decision function fails, then the entire test is considered to fail. Subclasses initialize the key-decision table dynamically. The method loadDecision is a framework method which subclasses MUST override to add each key-decision pair to a dictionary.


ITestMultiplexer - Member Functions and Data by Group

Constructors & Destructor

Class constructors and destructors.


[view class]
~ITestMultiplexer
public:
virtual ~ITestMultiplexer()
Destructor.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
operator =
public:
ITestMultiplexer& operator =( const ITestMultiplexer& copyIn )
Standard assignment operator. The parameter copyIn specifies the ITestMultiplexer object used to do the assignment.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
ITestMultiplexer


Overload 1
protected:
ITestMultiplexer(const ITestMultiplexer& copyIn)
Copy constructor.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 2
protected:
ITestMultiplexer( const IString& theKey, unsigned int howManyInputsAsKeys = 0 )
Constructor taking the key and the number of inputs as keys.
theKey
The decision key used for the current key.
howManyInputsAsKeys
The number of inputs that are interpreted as keys.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 3
protected:
ITestMultiplexer()
Default constructor.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Client Action Functions

Class member functions used to control the decision test functions to the test suite.


[view class]
addDecision
protected:
virtual void addDecision(const IString&, ITestDecisionFn)
Adds the pair aKey-aFunc to the dictionary.

Subclasses should call addDecision in their loadDecisions method to register each decision function which they have defined or overridden.

Subclasses should register overridden decision functions with the same key that the base class uses.

key
The key to add to the dictionary.
ITestDecisionFn fun
The decision function to add.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
andAllDecisions
protected:
virtual bool andAllDecisions()
Called by ITest if the key kAllDecisions is in effect.

Calls all decision functions (including those in base classes which have not been overridden), performs logical AND of their return values, and returns the result. You should not call this method directly. Override this function if you need to change its behavior.

Return

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
handleDecision
protected:
virtual bool handleDecision( ITestDecisionFn, const IString& )
This method executes the decision function and returns the result.

You can override this function to customize the execution of the decision function, for example, to write information to log or to catch certain exceptions thrown by the function. To override handleDecision, add code before and/or after calling the decision functions. If not overridden, handleDecision just calls the decision function and returns the result boolean value.

ITestDecisionFn
The decision function to run.
IString&
The key of the decision function. If not overridden, the key is ignored.

Return

Overriding

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
loadDecisions
protected:
virtual void loadDecisions()
A framework method for subclasses to override.

Inside loadDecisions subclasses must first call the inherited implementation (IDervied::loadDecisions must call IBase::loadDecisions). Then loadDecisions should register each key-decision function pair by calling addDecisions(theKey, theFunc), where theKey and theFunc are the key and the address of the decision member function. If a subclass has overridden a decision member function in its base class, it must register the keyword and the subclass's version of the function in loadDecisions. Do not call loadDecisions; it is called by ITestMultiplexer.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
print
protected:
virtual void print(ITieredTextBuffer&)
Prints the keys used for running the test to the given ITieredTextBuffer. Do not call this function directly.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
test
protected:
virtual void test()

Runs specified decision functions and returns logical AND of the results.

Runs whatever decision functions have previously been specified by their keys and calls setSuccess with the logical AND of the results.

Note: Contrary to usual ITest practice, subclasses should not override this method. Instead, subclasses should do the following:

Do not call this method directly; it is called by ITest::run.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Decision Key Methods

Class member functions used to indicate which decision test functions should be executed.


[view class]
decisionKey
public:
virtual void decisionKey(IString& dest) const
Sets the argument dest to the current decision key. If input AsKey is set to zero, returns a NULL string.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
inputsAsKeys
public:
virtual unsigned int inputsAsKeys() const
Returns the current value of fInputsAsKeys.

Return

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
setDecisionKey
public:
virtual bool setDecisionKey(const IString& key)
Sets the key that will be used in subsequent calls to test. Returns false and does nothing if the key is not valid; otherwise, returns true.

Use the key ITestMultiplexer::kAllDecisions to specify that all decision functions are to be run. The setDecisionKey function calls setInputAsKeys(0) so that no inputs will be interpreted as keys.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
setInputsAsKeys
public:
virtual void setInputsAsKeys(unsigned int howMany)
Allows you to specify how many of the ITest input arguments, starting with the first one, will be interpreted as keys.

Calling setInputsAsKeys with a nonzero value overrides any current key set via setDecisionKey, and causes decisionKey to return an empty string. Calling setInputsAsKey(0) will reactivate any key previously set via setDecisionKey, or the key kAllDecisions if setDecisionKey has not been called.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
kAllDecisions
The key ITestMultiplexer::kAllDecisions has the effect of running all decision functions and doing a logical AND of the test results. Initial value is "All".


Overload 1
This variation is used for AIX platforms.
public:
static const IString& kAllDecisions

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 2
The "_Import" variation is used for all non-AIX platforms.
public:
static const IString & _Import kAllDecisions

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


ITestMultiplexer - Inherited Member Functions and Data

Inherited Public Functions

ITest

Inherited Public Data

ITest

Inherited Protected Functions

ITest

Inherited Protected Data