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.
Constructors & DestructorClass constructors and destructors.
![]() |
public:
virtual ~ITestMultiplexer()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
ITestMultiplexer& operator =( const ITestMultiplexer& copyIn )
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
ITestMultiplexer(const ITestMultiplexer& copyIn)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
protected:
ITestMultiplexer( const IString& theKey, unsigned int howManyInputsAsKeys = 0 )
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
protected:
ITestMultiplexer()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Client Action FunctionsClass member functions used to control the decision test functions to the test suite.
![]() |
protected:
virtual void addDecision(const IString&, ITestDecisionFn)
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.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual bool andAllDecisions()
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.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual bool handleDecision( ITestDecisionFn, const IString& )
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.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void loadDecisions()
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.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void print(ITieredTextBuffer&)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
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.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Decision Key MethodsClass member functions used to indicate which decision test functions should be executed.
![]() |
public:
virtual void decisionKey(IString& dest) const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
virtual unsigned int inputsAsKeys() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
virtual bool setDecisionKey(const IString& key)
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.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
virtual void setInputsAsKeys(unsigned int howMany)
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.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
static const IString& kAllDecisions
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
public:
static const IString & _Import kAllDecisions
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
virtual ~ITest()
virtual void copyInfo()
void copyInputs(int& argc, char * *& argv) const
virtual EStage exceptionStage() const
virtual bool lookupInfo(const IString& key, IString& info)
ITest& operator =(const ITest& test)
ITieredTextBuffer& outputTextStream()
virtual void run()
virtual unsigned long runCount() const
void setInputs(const int argc, const char * const* argv)
bool success() const
static const IString& kComponentKey
static const IString & _Import kComponentKey
static const IString & _Import kDescriptionKey
static const IString& kDescriptionKey
static const IString & _Import kInputSyntaxKey
static const IString& kInputSyntaxKey
static const IString& kTargetClassKey
static const IString & _Import kTargetClassKey
static const IString& kTestNameKey
static const IString & _Import kTestNameKey
static const IString& kTestTypeKey
static const IString & _Import kTestTypeKey
static const IString& kTestVersionKey
static const IString & _Import kTestVersionKey
virtual void addInfo(const IString&, const IString&)
virtual void cleanup()
virtual bool isReset() const
virtual bool isSuccessUndecided() const
ITest()
ITest(const ITest& test)
virtual void reset()
virtual void setStickySuccess(bool success)
virtual void setSuccess(bool success)
virtual void setup()
virtual void test() = 0