Menu

Testing class which needs gui event loop

Help
beni
2006-08-28
2013-04-22
  • beni

    beni - 2006-08-28

    Hello, I am a newbie cppunit user. By looking at examples, I have successfully used cppunit to unit test my individual classes without a problem. I have started to feel the effectiveness and importance of unit testing via cppunit. Helper macros are great that it shields the developer againts many details. Now as my development procedes I have reached to a point that my classes needs the gui event loop to be tested. I am developing a qt 3.2.3 application with windows .net 2003 c++ compiler. I need the application context and hook into the gui event loop to be able to test some of the classes I have written. For example, I have udp socket server. It is uses qsockernotifier. Unfortunately in qt3 this notifier needs gui event loop. I really need some advice. Otherwise usage of cppunit will not be able to go over testing some small, allmost independent classes which is definetely not enough. In summary, HOW CAN I HOOK INTO QT EVENT LOOP IN CPPUNIT AND CREATE THE APPLICATION CONTEXT WHILE TEST ARE RUNNING AND PERFORM THE TEST, QUIT THE APPLICATION SO THAT THE TEST SUIT MAY PROCEED TO THE OTHER TESTS

     
    • Felix Deutsch

      Felix Deutsch - 2006-09-20

      Use a single shot timer event (with a suitable delay) connected to a slot that calls your tests, i.e. the slot method would have the usual cppunit test setup stuff and runner.run().

      So your app gets initialized as usual, then, once the singleshot timer fires, your're executing your testcases as usual while being inside the QT event loop.
      You may want to hand over the application context to the object containing the slot running the testcases though, so you can call processEvents() and other methods as needed.

       

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.