How To Use
|
Overview
Assuming you have a complex interaction of your test object with several objects within its environment. A good test will observe that all objects of the environment are called with correct methods and parameter values and in the correct call sequence.
But when you have verified within a test case that all these calls to the environment are correct you may have many additional test cases each focussing on some special (error) behaviour concerning only a single aspect/component within the environment. In those test cases it is no longer needed to again check in detail the interaction to all other components of the environment.
The following sections give advice to reduce the amount of repeated checks via a series of calls to TTB_EXP.
Instrument the fake objects within your test environment only for those test cases where you really need to watch the calls to them.
If your test objects derive from TTB::SimulatedObjectBase you have the generic possibility to switch verbosity of each method on and off by setting Option::oSILENT. For more details see http://www.gerald-fahrnholz.eu/sw/display_contents.php?file_name=simulated_objects.htm#headLine_9.
You can still record all interactions with environment objects. Within test case you simply verify only those interactions which are relevant. After the required checks delete all other recorded interactions via TheTestEvents()->ClearAllStoredEvents().
Example:
Tip
The recorded events are still visible within test protocol for analysis of error situations.
Assume you can collect relevant test events somehow within a text file, then you can check even lengthy contents within a single line within your test script by calling method CompareTextFiles:
Instead of checking recorded TestEvents with multiple calls to TTB_EXP you can export all not yet checked events to an external text file by calling method TransferEventsToTextFile. The generated text file can be checked by comparing it with a predefined pattern file:
You can import a text file with collected test data into TestEvents. With use of macros TTB_EXP or TTB_EXP_VAR you can verify only the interesting lines and forget about the rest of the file contents:
It is even possible to treat XML files as simple text files to perform selective checking:
For some cases this may be a simpler method to check XML contents than described in Comparing an xml tree with a pattern file.