MfcTestRunner.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef CPPUNITUI_MFC_MFCTESTRUNNER_H
  2. #define CPPUNITUI_MFC_MFCTESTRUNNER_H
  3. #if _MSC_VER >= 1000
  4. #pragma once
  5. #endif // _MSC_VER >= 1000
  6. #include <cppunit/Portability.h>
  7. #include <cppunit/portability/CppUnitVector.h>
  8. /* Refer to MSDN documentation to know how to write and use MFC extension DLL:
  9. mk:@MSITStore:h:\DevStudio\MSDN\98VSa\1036\vcmfc.chm::/html/_mfcnotes_tn033.htm#_mfcnotes_how_to_write_an_mfc_extension_dll
  10. This can be found in the index with "mfc extension"
  11. The basic:
  12. Using:
  13. - your application must use MFC DLL
  14. - memory allocation is done using the same heap
  15. - you must define the symbol _AFX_DLL
  16. Building:
  17. - you must define the symbol _AFX_DLL and _AFX_EXT
  18. - export class using AFX_EXT_CLASS
  19. */
  20. CPPUNIT_NS_BEGIN
  21. class Test;
  22. class TestSuite;
  23. /*! \brief MFC test runner.
  24. * \ingroup ExecutingTest
  25. *
  26. * Use this to launch the MFC TestRunner. Usually called from you CWinApp subclass:
  27. *
  28. * \code
  29. * #include <cppunit/ui/mfc/MfcTestRunner.h>
  30. * #include <cppunit/extensions/TestFactoryRegistry.h>
  31. *
  32. * void
  33. * CHostAppApp::RunUnitTests()
  34. * {
  35. * CppUnit::MfcTestRunner runner;
  36. * runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() );
  37. *
  38. * runner.run();
  39. * }
  40. * \endcode
  41. * \see CppUnit::TextTestRunner, CppUnit::TestFactoryRegistry.
  42. */
  43. class AFX_EXT_CLASS MfcTestRunner
  44. {
  45. public:
  46. MfcTestRunner();
  47. virtual ~MfcTestRunner();
  48. void run();
  49. void addTest( Test *test );
  50. void addTests( const CppUnitVector<Test *> &tests );
  51. protected:
  52. Test *getRootTest();
  53. TestSuite *m_suite;
  54. typedef CppUnitVector<Test *> Tests;
  55. Tests m_tests;
  56. };
  57. CPPUNIT_NS_END
  58. #endif // CPPUNITUI_MFC_MFCTESTRUNNER_H