Exemplo n.º 1
0
    Framework::ReturnCode Framework::run() {
        Ensures(m_program_options.parse_options());

        if (m_program_options.asked_for_help()) {
            return help();
        }

        if (m_program_options.asked_for_list()) {
            return list();
        }

        CPPUNIT_NS::TextUi::TestRunner runner;

        if (m_program_options.asked_to_run_only_some_tests()) {
            Ensures(combine_tests_subset(runner));
        } else if (m_program_options.asked_for_regtest()) {
            Ensures(combine_regtest_subset(runner));
        } else {
            runner.addTest(get_registry()->makeTest());
        }

        CPPUNIT_NS::TestResult controller;

        CPPUNIT_NS::TestResultCollector result;
        controller.addListener(&result);

        CPPUNIT_NS::BriefTestProgressListener progress;
        controller.addListener(&progress);
        runner.run(controller);

        CPPUNIT_NS::CompilerOutputter outputter(&result, std::cerr);
        outputter.write();

        return result.wasSuccessful() ? SUCCESS : FAILURE;
    }
Exemplo n.º 2
0
int main(int argc, char**argv) {
  CPPUNIT_NS::TextUi::TestRunner runner;
  CPPUNIT_NS::TestFactoryRegistry &registry = CPPUNIT_NS::TestFactoryRegistry::getRegistry();
  runner.addTest( registry.makeTest() );
  bool wasSuccessful = runner.run();
  return wasSuccessful ? 0 : 1;
}
Exemplo n.º 3
0
int main() {
#if defined (_MSC_VER) && defined (CHECK_HEAP) && _MSC_VER >= 1200 
	_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) |
				  _CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF |
	_CRTDBG_CHECK_ALWAYS_DF);

	_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
	_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR );
	_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
	_CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDERR );
	_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
	_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
#endif

  // Get the top level suite from the registry
  CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();

  // Adds the test to the list of test to run
  CPPUNIT_NS::TextUi::TestRunner runner;
  runner.addTest( suite );

  // Change the default outputter to a compiler error format outputter
  runner.setOutputter( new CPPUNIT_NS::CompilerOutputter( &runner.result(), std::cout ) );
  
  // Run the test.
  bool wasSucessful = runner.run();

  // Return error code 1 if the one of test failed.
  return wasSucessful ? 0 : 1;
}
Exemplo n.º 4
0
int main() {
  CPPUNIT_NS::TextUi::TestRunner runner;
  CppUnit::BriefTestProgressListener listener;
  runner.eventManager().addListener(&listener);
  runner.setOutputter(new CPPUNIT_NS::CompilerOutputter(&runner.result(),
    CPPUNIT_NS::stdCOut()));
  bool wasSucessful = runner.run();
  return wasSucessful ? 0 : 1;
}
Exemplo n.º 5
0
int main()
{
  CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
  CPPUNIT_NS::TextUi::TestRunner runner;
  runner.addTest( suite );
  runner.setOutputter( new CPPUNIT_NS::CompilerOutputter( &runner.result(),
                                                          CPPUNIT_NS::stdCOut() ) );
  bool wasSucessful = runner.run();
  return wasSucessful ? 0 : 1;
}
Exemplo n.º 6
0
int main( int argc, char* argv[] )
{
    std::ofstream oTestRst("TestQBase.xml");
    CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
    CPPUNIT_NS::TextUi::TestRunner runner;

    runner.addTest(suite);
    runner.setOutputter(new CPPUNIT_NS::XmlOutputter(&runner.result(), oTestRst));
    runner.run();

    return 0;
}
Exemplo n.º 7
0
int 
main(int argc, char** argv)
{
  CPPUNIT_NS::TextUi::TestRunner runner;

  runner.addTest( BoardGameTest<BoardGame>::suite() );
  runner.addTest( ChessTest<Chess>::suite() );

  bool wasSuccessful = runner.run();

  return wasSuccessful ? 0 : 1;
}
Exemplo n.º 8
0
int main (int argc, char* argv[])
{
    //wxLog::AddTraceMask (_T("wxGuiTestCallTrace"));

    // Configure unit testing:
    wxTst::WxGuiTestHelper::SetShowModalDialogsNonModalFlag (true);
    wxTst::WxGuiTestHelper::SetShowPopupMenusFlag (false);
    // Disable interactivity for really running automatic tests:
    //wxTst::WxGuiTestHelper::SetDisableTestInteractivity (true);
    // Likewise, prevent pop-up warning message box on failing assertions:
    //wxTst::WxGuiTestHelper::SetPopupWarningForFailingAssert (false);
    // But do check provoked warnings in testing mode:
	wxTst::WxGuiTestHelper::SetCheckForProvokedWarnings (true);
    // Which requires the correct CppUnit warning asserter:
    wxTst::WxGuiTestHelper::SetWarningAsserter (
            new wxTst::CppUnitWarningAsserter ());

    // Record wxVtk interaction:
    //wxTst::VtkWxGuiTestHelper::SetUseWxVtkInteractionRecording (true);

    // Create AUT:
    MyApp* myApp = new MyApp ();
    
    // wxTst::InitWxGuiTest, which "packs" all registered wxWidgets GUI tests
    // into decorated shape, must not use CPPUNIT_TEST_SUITE_REGISTRATION macro
    // when WxGuiTesting is built as an independent and reusable library.
    // Thus, in order to use the remaining standard infrastructure, we create a
    // new test suite named equal to the usual top level registry or suite name
    // "All Tests". Then all registered wxGui tests are added to it by means of
    // directly using InitWxGuiTest class:
    CPPUNIT_NS::TestSuite *suite = new CPPUNIT_NS::TestSuite ("All Tests");
    suite->addTest (wxTst::InitWxGuiTest::suite ());

    // Adds the test to the list of test to run
    CPPUNIT_NS::TextUi::TestRunner runner;
    runner.addTest (suite);

    // Change the default outputter to a compiler error format outputter
     runner.setOutputter (new CPPUNIT_NS::CompilerOutputter (&runner.result (),
             OUTPUT));

    // Run the test - don't close window in debug mode at the end
    bool wasSucessful = runner.run ();

    // Return error code 1 if the one of test failed.
    return wasSucessful ? 0 : 1;
}
Exemplo n.º 9
0
int main(int argc, char* argv[])
{
	// Get the top level suite from the registry
	CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();

	// Adds the test to the list of test to run
	CPPUNIT_NS::TextUi::TestRunner runner;
	runner.addTest( suite );

	// Change the default outputter to a compiler error format outputter
	runner.setOutputter( new CPPUNIT_NS::CompilerOutputter( &runner.result(), std::cerr ) );
	// Run the test.
	bool wasSucessful = runner.run();

	// Return error code 1 if the one of test failed.
	return wasSucessful ? 0 : 1;
}
Exemplo n.º 10
0
int main() {
  CPPUNIT_NS::TextUi::TestRunner runner;
  CppUnit::BriefTestProgressListener listener;
  runner.addTest(ServiceLocatorServletTester::suite());
  runner.addTest(ServiceLocatorClientTester::suite());
  runner.addTest(AuthenticationServletAdapterTester::suite());
  runner.eventManager().addListener(&listener);
  runner.setOutputter(new CPPUNIT_NS::CompilerOutputter(&runner.result(),
    CPPUNIT_NS::stdCOut()));
  bool wasSucessful = runner.run();
  return wasSucessful ? 0 : 1;
}
Exemplo n.º 11
0
int main() {
  CPPUNIT_NS::TextUi::TestRunner runner;
  CppUnit::BriefTestProgressListener listener;
  runner.addTest(MessageProtocolTester::suite());
  runner.addTest(ServiceProtocolClientTester::suite());
  runner.addTest(ServiceProtocolServerTester::suite());
  runner.addTest(ServiceProtocolServletContainerTester::suite());
  runner.eventManager().addListener(&listener);
  runner.setOutputter(new CPPUNIT_NS::CompilerOutputter(&runner.result(),
    CPPUNIT_NS::stdCOut()));
  bool wasSucessful = runner.run();
  return wasSucessful ? 0 : 1;
}
Exemplo n.º 12
0
int 
main(int argc, char** argv)
{
	wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program");
	
	wxInitializer initializer;
	if ( !initializer )
	{
		fprintf(stderr, "Failed to initialize the wxWidgets library, aborting.");
		return -1;
	}


	// We are using .png files for some extra bitmaps.
	wxImageHandler * pnghandler = new wxPNGHandler;
	wxImage::AddHandler(pnghandler);
	wxImage::AddHandler(new wxGIFHandler);

	mutaborGUI::initMutIconShapes();
	mutaborGUI::InitGUIRouteFactories();


	

#ifdef _GLIBCXX_DEBUG
	std::clog << "In case of segmentation faults assure that cppunit is compiled using -D_GLIBCXX_DEBUG" << std::endl;
#endif

	CPPUNIT_NS::TextUi::TestRunner runner;
	
	CppUnit::BriefTestProgressListener listener; 
	runner.eventManager().addListener(&listener);

	runner.addTest( MkIDlist::suite() );
	
	bool wasSuccessful = runner.run();

	return wasSuccessful ? 0 : 1;
}
Exemplo n.º 13
0
int main() {
  CPPUNIT_NS::TextUi::TestRunner runner;
  CppUnit::BriefTestProgressListener listener;
  runner.addTest(CodedReaderTester::suite());
  runner.addTest(CodedWriterTester::suite());
  runner.addTest(NullDecoderTester::suite());
  runner.addTest(NullEncoderTester::suite());
  runner.addTest(SizeDeclarativeDecoderTester::suite());
  runner.addTest(SizeDeclarativeEncoderTester::suite());
  runner.eventManager().addListener(&listener);
  runner.setOutputter(new CPPUNIT_NS::CompilerOutputter(&runner.result(),
    CPPUNIT_NS::stdCOut()));
  bool wasSucessful = runner.run();
  return wasSucessful ? 0 : 1;
}
Exemplo n.º 14
0
    bool Framework::combine_tests_subset(CPPUNIT_NS::TextUi::TestRunner &runner) const {
        FindTest find_test;

        for (auto &name : m_program_options.get_tests_to_run()) {
            CPPUNIT_NS::Test *test = find_test(name, get_registry()->makeTest());

            if (test == nullptr) {
                std::cerr << "Cannot find test '" << name << "'!" << std::endl;
                return false;
            }

            runner.addTest(test);
        }

        return true;
    }
Exemplo n.º 15
0
    bool Framework::combine_regtest_subset(CPPUNIT_NS::TextUi::TestRunner &runner) const {
        FindRegTest find_regtest;

        try {
            auto tests_to_run = find_regtest(m_program_options.get_regtest(), get_registry()->makeTest());

            for (auto &test : tests_to_run) {
                runner.addTest(test);
            }
        } catch (const std::exception &e) {
            std::cerr << "Cannot match your regexp: " << e.what() << std::endl;
            return false;
        }

        return true;
    }
Exemplo n.º 16
0
int main() {
  CPPUNIT_NS::TextUi::TestRunner runner;
  CppUnit::BriefTestProgressListener listener;
  runner.addTest(SequenceTester::suite());
  runner.addTest(SequencedValueTester::suite());
  runner.addTest(IndexedValueTester::suite());
  runner.addTest(SnapshotLimitTester::suite());
  runner.addTest(RangeTester::suite());
  runner.addTest(RangedQueryTester::suite());
  runner.addTest(SnapshotLimitedQueryTester::suite());
  runner.addTest(InterruptableQueryTester::suite());
  runner.addTest(IndexedQueryTester::suite());
  runner.addTest(NativeDataTypeTester::suite());
  runner.addTest(NativeValueTester::suite());
  runner.addTest(ConstantExpressionTester::suite());
  runner.addTest(FilteredQueryTester::suite());
  runner.addTest(ConstantEvaluatorNodeTester::suite());
  runner.addTest(ParameterExpressionTester::suite());
  runner.addTest(ParameterEvaluatorNodeTester::suite());
  runner.addTest(EvaluatorTester::suite());
  runner.addTest(FunctionExpressionTester::suite());
  runner.addTest(FunctionEvaluatorNodeTester::suite());
  runner.addTest(ConversionEvaluatorNodeTester::suite());
  runner.addTest(MemberAccessExpressionTester::suite());
  runner.addTest(MemberAccessEvaluatorNodeTester::suite());
  runner.addTest(OrExpressionTester::suite());
  runner.addTest(OrEvaluatorNodeTester::suite());
  runner.addTest(ReduceExpressionTester::suite());
  runner.addTest(ReduceEvaluatorNodeTester::suite());
  runner.addTest(SequencedValuePublisherTester::suite());
  runner.addTest(SubscriptionsTester::suite());
  runner.addTest(LocalDataStoreTester::suite());
  runner.addTest(BufferedDataStoreTester::suite());
  runner.addTest(CachedDataStoreTester::suite());
  runner.addTest(SessionCachedDataStoreTester::suite());
  runner.addTest(ExpressionSubscriptionsTester::suite());
  runner.eventManager().addListener(&listener);
  runner.setOutputter(new CPPUNIT_NS::CompilerOutputter(&runner.result(),
    CPPUNIT_NS::stdCOut()));
  bool wasSucessful = runner.run();
  return wasSucessful ? 0 : -1;
}
Exemplo n.º 17
0
EXPORTAPI _CppUnit_RunAllTests_ByName(
							   IN int argc,
							   IN WCHAR** wargv,
							   IN const std::string& strName)
{
	USES_CONVERSION;
	
	LPCWSTR pwszFileName = NULL;
	
	if (wargv != NULL)
	{
		LPCWSTR pwszModule = CPPUNIT_NOFILTER_MODULE;
		LPSTR pszTestClass = CPPUNIT_NOFILTER_TESTCLASS;
		LPSTR pszTestMethod = CPPUNIT_NOFILTER_TESTMETHOD;
		for (int i = 1; i < argc; ++i)
		{
			if (wargv[i][0] == '/' || wargv[i][0] == '-')
			{
				if (_wcsnicmp(wargv[i]+1, _g_outputsw, countof(_g_outputsw)) == 0)
				{
					pwszFileName = wargv[i] + (1 + countof(_g_outputsw)); // 测试结果文件
				}
				else if (_wcsnicmp(wargv[i]+1, _g_runsw, countof(_g_runsw)) == 0)
				{
					LPCWSTR pwszRunParam = wargv[i] + (1 + countof(_g_runsw));
					pszTestClass = W2A(pwszRunParam);
					pszTestMethod = strchr(pszTestClass, '.');
					if (pszTestMethod)
						*pszTestMethod++ = '\0';
				}
			}
		}
		if (_g_runtype == rununitNone)
		{
			pwszModule = _CppUnit_ModuleFilterName(wargv[0]);
		}
		
		_CppUnit_FilterCase(pwszModule, pszTestClass, pszTestMethod);
	}
	
	// 创建案例
	CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry(strName).makeTest();
	CPPUNIT_NS::TextUi::TestRunner runner;
	runner.addTest( suite );
	
	CPPUNIT_NS::Outputter* outputter = NULL;
	std::ofstream outfile;
	if (pwszFileName)
		outfile.open(W2A(pwszFileName), std::ios::out | std::ios::app);
	if (outfile.is_open())
		outputter = new CPPUNIT_NS::XmlOutputter(&runner.result(), outfile);
	else
		outputter = new CPPUNIT_NS::CompilerOutputter(&runner.result(), std::cerr);
	
	runner.setOutputter(outputter);
	
	try {
		std::for_each(
			_g_regProcs.begin(),
			_g_regProcs.end(),
			_RunInitializeProc());
	}
	catch (...) {
		if (outfile.is_open()) {
			outfile << "<Exception_In__RunInitializeProc/>" << std::endl;
		}
		else {
			std::cerr << " Caught an exception in _RunInitializeProc()!" << std::endl;
		}
		return E_FAIL;
	}
	
	bool wasSucessful = runner.run();
	
	try {
		std::for_each(
			_g_regProcs.rbegin(),
			_g_regProcs.rend(),
			_RunTerminateProc());
	}
	catch (...) {
		if (outfile.is_open()) {
			outfile << "<Exception_In__RunTerminateProc/>" << std::endl;
		}
		else {
			std::cerr << " Caught an exception in _RunTerminateProc()!" << std::endl;
		}
		return E_FAIL;
	}
	
	return wasSucessful ? S_OK : E_FAIL;
}