title: Testing with Qt's QTestLib module
body: <p>I started writing some tests with Qt's unit testing system.</p>
  
  <p>How do you usually organize the tests? It is one test class per one module class, or do you test the whole module with a single test class? Qt docs suggest to follow the former strategy.</p>
  
  <p>I want to write tests for a module. The module provides only one class that is going to be used by the module user, but there is a lot of logic abstracted in other classes, which I would also like to test, besides testing the public class.</p>
  
  <p>The problem is that Qt's proposed way to run tests involved the <code>QTEST_MAIN</code> macro:</p>
  
  <pre><code>QTEST_MAIN(TestClass)
  #include "test_class.moc"
  </code></pre>
  
  <p>and eventually one test program is capable of testing just one test class. And it kinda sucks to create test projects for every single class in the module.</p>
  
  <p>Of course, one could take a look at the <code>QTEST_MAIN</code> macro, rewrite it, and run other test classes. But is there something, that works out of the box?</p>
  
  <p>So far I do it by hand:</p>
  
  <pre><code>#include "one.h"
  #include "two.h"
  
  int main(int argc, char *argv[]) 
  { 
      QCoreApplication app(argc, argv); 
      TestOne one;
      QTest::qExec(&amp;one, argc, argv);
      TestOne two;
      QTest::qExec(&amp;two, argc, argv);
  }
  </code></pre>