views:

289

answers:

1

I'm just starting to use QTestLib. I have gone through the manual and tutorial. Although I understand how to create tests, I'm just not getting how to make those tests convenient to run. My unit test background is NUnit and MSTest. In those environments, it was trivial (using a GUI, at least) to alternate between running a single test, or all tests in a single test class, or all tests in the entire project, just by clicking the right button.

All I'm seeing in QTestLib is either you use the QTEST_MAIN macro to run the tests in a single class, then compile and test each file separately; or use QTest::qExec() in main() to define which objects to test, and then manually change that and recompile when you want to add/remove test classes.

I'm sure I'm missing something. I'd like to be able to easily:

  • Run a single test method
  • Run the tests in an entire class
  • Run all tests

Any of those would call the appropriate setup / teardown functions.

EDIT: Bounty now available. There's got to be a better way, or a GUI test runner that handles it for you or something. If you are using QtTest in a test-driven environment, let me know what is working for you. (Scripts, test runners, etc.)

A: 

You can run only selected test cases (test methods) by passing test names as command line arguments :

myTests.exe myCaseOne myCaseTwo

It will run all inits/cleanups too. Unfortunately there is no support for wildcards/pattern matching, so to run all cases beginning with given string (I assume that's what you mean by "running the tests in an entire class"), you'd have to create script (windows batch/bash/perl/whatever) that calls:

myTests.exe -functions

parses the results and runs selected tests using first syntax.

To run all cases, just don't pass any parameter:

myTests.exe
chalup
Maybe they will improve the functionality in a future version....
Dave