Creating a base test class

The simplest way to create a test class is to derive it directly from TTest. In this way, your test uses an instance of the class you are testing. Figure 2 shows an example of this simple structure.


Figure 3 shows a better approach that gives you more flexibility by creating a base test class for your tests. As you write more tests, you can put common functions and data in the base test class.


Figure 4 shows the class hierarchy for the TSampleObject test classes. In addition to creating an organized structure for your tests, you can use a simple naming convention to clarify which test classes relate to the classes you are testing. For example, the test class for TSampleObject that tests the string functions is called TSampleObjectStringTest. The test class for the MaxLength member functions is TSampleObjectLengthTest.



[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker