title: wxWidgets: How to initialize wxApp without using macros and without entering the main application loop?
body: <p>We need to write unit tests for a <em>wxWidgets</em> application using <em>Google Test Framework</em>.
  The problem is that <em>wxWidgets</em> uses the macro <strong>IMPLEMENT_APP(MyApp)</strong> to initialize and enter the application main loop. This macro creates several functions including <strong>int main()</strong>. The google test framework also uses macro definitions for each test. </p>
  
  <p>One of the problems is that it is not possible to call the wxWidgets macro from within the test macro, because the first one creates functions.. So, we found that we could replace the macro with the following code:</p>
  
  <pre><code>wxApp* pApp = new MyApp(); 
  wxApp::SetInstance(pApp);
  wxEntry(argc, argv);
  </code></pre>
  
  <p>That's a good replacement, but wxEntry() call enters the original application loop. If we don't call wxEntry() there are still some parts of the application not initialized.</p>
  
  <p>The question is how to initialize everything required for a wxApp to run, without actually running it, so we are able to unit test portions of it?</p>