Writing a simple test

Here is an example that shows the complete implementation of the TSimpleTest class. This class implements a single function, Test. The Test member function in this example prints a message to the console. In your test classes, the Test member function is where you write the code that performs the test.

Note that you use OutputTextStream to display messages. OutputTextStream is a TTest member function that allows you to record the text you display in a text buffer stored within the TTest instance. Use this member function or a related method to display messages in your tests.

      // File: SimpleTest.C
      // Copyright (C) 1995 Taligent, Inc. All rights reserved.
      
      #ifndef Taligent_TEST
      #include <Taligent/Test.h>
      #endif
      
      class TSimpleTest : public TTest {
      public:
                          TSimpleTest();
          virtual         ~TSimpleTest();
      
      protected:
      // Override the Test member function and write the test you want to perform
          virtual void    Test();
      
      private:
          MCollectibleDeclarationsMacro(TSimpleTest);
      };
      
      TSimpleTest::TSimpleTest() { }
      
      TSimpleTest::~TSimpleTest() { }
      
      MCollectibleDefinitionsMacro(TSimpleTest,0);
      
      void TSimpleTest::Test()
      {
      // This is the member function in which you write the code for your test
          OutputTextStream() << "TSimpleTest - Test method called.\n";
          SetSuccess(true);
      }

[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