Menu

Initialiser for test class

2001-06-26
2001-07-13
  • Anthony Novak

    Anthony Novak - 2001-06-26

    Hi Guys,
    I know i probably missing the point here, but how can i get a static initialiser for a class. Say for example i want to test a class. The testing thread should initialise MS COM (CoInitializeEx) once when the tests begin. At the end of all the tests it should uninitialise (CoUninitialise).
    I see that setUp and tearDown are called for every test. and using the test class contructor yeilds the same result.

    Any ideas?

    Many regards

    APN

     
    • Baptiste Lepilleur

      I'm not sure what you are calling a "static initializer".

      Initialization should be done in the setUp() and tearDown() methods which are called for each run, in the testing thread.

      In VC++ TestRunner, test are run in a separate worker thread.

      The constructor and destructor are "called" in the thread that constructs the testcase, that is the GUI TestRunner thread (note that there is an instance for each test method in a testcase).

      If you don't use setUp() and tearDown(), some tests might misbehave when you "rerun" them (useful when debugging).

      There is no way at the current time to decorate the test being run in the test runner.

       
    • Kent Dahl

      Kent Dahl - 2001-07-13

      I believe you could wrap it using TestSetup, thou I can't get it to work properly myself... (and the 1.5.5 download still has a bug in TestSetup.h)

      So I'd try to make a subclass of TestSetup, do the init in setUp, and uninit in tearDown, then wrap MyTestSetup around a suite containing the tests that need that resource.

      (I just tried it, and after fixing TestSetup.h, I still had to implement run in my subclass to make it call my setUp and tearDown. Time to do a CVS checkout, and live on the bleedin' edge :-)

      Just my 0.02 NOK

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.