is it possible to run one test at a time?

sdsource
2009-05-21
2013-04-22
  • sdsource
    sdsource
    2009-05-21

    i'm using texttestrunner to run all the tests at once. I want to know if it is possible to run one test at a time and how. Thanks

     
    • Timo
      Timo
      2009-07-22

      You can not specify a specific test that should be run from the command line if you mean that.
      We had the same problem...
      The only thing you could do is to isolate the test that you want to execute in a header/cpp file and compile it separately as a small library.
      We divided our unit tests in various (10-15) libraries (per module one library). Due to that we have the possibility to include all libraries and link them altogether with the Texttestrunner to execute our whole test suite (for example to ensure the integrity on the build server). On the other hand it's also possible to include only one library to test one specific module. The same could be done for only one test of course. However if you have many tests and you like to do this with all of them then this is not a feasible approach.
      Sorry, but I think that is all that you could do. :-(

      Cheers
      Timo

       
    • Kent Dahl
      Kent Dahl
      2009-07-22

      I'm not sure if the default TextTestRunner has this by default, but at work I created my own runner (i.e. main function) that parses the command line arguments and passes an argument into the FindTest function. (I created by own main function since I also wanted a verbose output toggle.)

      You then only use the TestFactoryRegistry to collect the tests into one set and search that set for one or more tests, given a string like MyTest or MyTest::Test1 to select a specific or group of tests.

      Basically I used the code on this page and dug for five minutes in the API docs to get what I wanted:
      http://cppunit.sourceforge.net/doc/lastest/cppunit_cookbook.html