示例#1
0
int main(int /*argc*/, char** /*argv*/)
{
	CppUnit::Test *suite =
		CppUnit::TestFactoryRegistry::getRegistry().makeTest();

	CppUnit::TextTestRunner runner;
	runner.addTest( suite );

	runner.setOutputter(
		new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) );

	bool wasSucessful = runner.run();

	return wasSucessful ? 0 : 1;
}
示例#2
0
int main (int argc, char *argv[])
{

    // Start MPI if this is a parallel build.
#if RUNMPI == true
    MPI_Init(&argc, &argv);
#endif

    // Print a header message.
#if RUNMPI == true
    if (MPICommons::isMaster())
    {
        CppUnit::stdCOut() << std::endl << "Running KMCLib C++ unit tests on " << MPICommons::size() << " MPI processes." << std::endl;
    }
#else
    CppUnit::stdCOut() << std::endl << "Running KMCLib C++ unit tests." << std::endl;

#endif

    // Setup the tests.
    CppUnit::Test *test = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    CppUnit::TextTestRunner runner;
    runner.addTest(test);

    // Add our custom outputter.
    runner.setOutputter( new CustomOutputter(&runner.result(),
                                             std::cout) );

    // Add our custom progress listener.
    CppUnit::TestResult & event_manager = runner.eventManager();
    CustomProgressListener progress;
    event_manager.addListener( &progress );

    // Run the tests.
    runner.run(std::string(""), false, true, false);

    // Remove the progress listener.
    event_manager.removeListener( &progress );

    // Finalize if MPI.
#if RUNMPI == true
    MPI_Finalize();
#endif

    // DONE
    return 0;
}
int main(int argc,char **argv)
{
    //setup the test runner
    CppUnit::TextTestRunner runner;
    CppUnit::TextTestProgressListener progress;
    CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
    
    runner.addTest(registry.makeTest());
    runner.eventManager().addListener(&progress);

    std::ofstream os("unittest.xml");
    runner.setOutputter(new CppUnit::XmlOutputter(&runner.result(),os));
    
    bool result = runner.run();

    return result ? 0 : 1;
}
void OsiTransportTest::run()
{
    // Do processing here

	CppUnit::TextTestRunner runner;
	runner.addTest(test1);
	runner.addTest(test2);
	runner.addTest(test3);

	runner.run();

	std::ofstream outFile("testResult.xml");
	CppUnit::XmlOutputter outputer(&runner.result(), outFile);
	outputer.write();

	emit finished();
}
示例#5
0
int main()
{
	// Get the top level suite from the test registry
	CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();

	// Add the test to the list of tests to run
	CppUnit::TextTestRunner runner;
	runner.addTest(suite);

	// Send the output to cerr when the compiler runs
	runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr));

	// Actually run the thing.
	bool successful = runner.run();

	// Return result
	return (successful ? 0 : 1);
}
示例#6
0
int main(int argc, char* argv[])
{
  // Get the top level suite from the registry
  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();

  // Adds the test to the list of test to run
  CppUnit::TextTestRunner runner;
  runner.addTest( suite );

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

  // Return error code 1 if the one of test failed.
  return wasSucessful ? 0 : 1;
}
示例#7
0
int main(int argc, char ** argv)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
	Agelena::Loggers::DefaultWindowsLogger logger;
#else
	Agelena::Loggers::DefaultPOSIXLogger logger;
#endif
	// UnitTest
	CppUnit::TextTestRunner runner;
	runner.setOutputter(CppUnit::CompilerOutputter::defaultOutputter(&runner.result(), std::cerr));
	CppUnit::BriefTestProgressListener progress;
	runner.eventManager().addListener( &progress );
	CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
	runner.addTest( registry.makeTest() );
	runner.run();

	return 0;
}
示例#8
0
int MWorksCoreTestMain(int argc, char *argv[]) {
    if (argc < 2) {
        std::cerr << "Usage: " << argv[0] << " results_file [test_name ...]" << std::endl;
        return 2;
    }

    if (NULL != getenv("MWORKS_PAUSE_FOR_DEBUGGER")) {
        std::cerr << "Waiting for debugger to attach...";
        pause();
        std::cerr << " continuing" << std::endl;
    }

    CppUnit::TextTestRunner runner;

    std::ofstream outfile( argv[1] );
    CppUnit::XmlOutputter *outputter = new CppUnit::XmlOutputter(&runner.result(), outfile);
    runner.setOutputter(outputter);

    MWorksTestProgressListener listener;
    runner.eventManager().addListener( &listener );

    CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry("Unit Test");
    runner.addTest( registry.makeTest() );

    bool returnval = true;
    if (argc > 2) {
        // Run specified tests
        for (int i = 2; i < argc; i++) {
            returnval = runner.run( argv[i], false, false, false ) && returnval;
        }
    } else {
        // Run all tests
        returnval = runner.run( "", false, false, false );
    }

    outputter->write();
    outfile.close();

    // return !returnval because it is 1 on success
    return !returnval;
}
示例#9
0
//CPPUNIT_TEST_SUITE_REGISTRATION(mystringTest);
int main()
{
    CppUnit::Test *test = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    CppUnit::TextTestRunner runner;
    runner.addTest(test);

    //new for formatting
    const std::string format("%p:%l");
    std::ofstream ofile;
    ofile.open("run.log");
    CppUnit::CompilerOutputter* outputter = new
        CppUnit::CompilerOutputter(&runner.result(),ofile);
    outputter->setLocationFormat(format);
    runner.setOutputter(outputter);


    runner.run();
    ofile.close();
    return 0;

}
示例#10
0
int main(int argc, char ** argv)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
    Agelena::Loggers::DefaultWindowsLogger logger;
#else
    Agelena::Loggers::DefaultPOSIXLogger logger;
#endif

    if (argc > 1)
        cert_path__ = boost::filesystem::path(argv[1], boost::filesystem::native);
    else
        std::cerr << "No path to the SSL certificate for the tests was specified - test won't be performed" << std::endl;;

    // UnitTest
    CppUnit::TextTestRunner runner;
    runner.setOutputter(CppUnit::CompilerOutputter::defaultOutputter(&runner.result(), std::cerr));
    CppUnit::BriefTestProgressListener progress;
    runner.eventManager().addListener( &progress );
    CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
    runner.addTest( registry.makeTest() );
    runner.run();

    return 0;
}
示例#11
0
int main(int argc, char* argv[])
{
    atexit(cleanup);
    printf("\nRing Daemon Test Suite, by Savoir-faire Linux 2004-2015\n\n");
    setConsoleLog(true);
    setDebugMode(true);
    ring::fileutils::FileHandle f(ring::fileutils::create_pidfile());
    if (f.fd == -1) {
        fprintf(stderr, "An dring instance is already running, quitting...\n");
        return 1;
    }

    int argvIndex = 1;
    bool xmlOutput = false;

    if (argc > 1) {
        if (strcmp("--help", argv[1]) == 0) {
            argvIndex++;

            CPPUNIT_NS::Test* suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry("All Tests").makeTest();

            int testSuiteCount = suite->getChildTestCount();
            printf("Usage: test [OPTIONS] [TEST_SUITE]\n");
            printf("\nOptions:\n");
            printf(" --xml - Output results in an XML file, instead of standard output.\n");
            printf(" --debug - Debug mode\n");
            printf(" --help - Print help\n");
            printf("\nAvailable test suites:\n");

            for (int i = 0; i < testSuiteCount; i++) {
                printf(" - %s\n", suite->getChildTestAt(i)->getName().c_str());
            }

            return 0;
        } else if (strcmp("--debug", argv[1]) == 0) {
            argvIndex++;

            setDebugMode(true);
            RING_INFO("Debug mode activated");

        } else if (strcmp("--xml", argv[1]) == 0) {
            argvIndex++;

            xmlOutput = true;
            RING_INFO("Using XML output");
        }
    }

    // Default test suite : all tests
    std::string testSuiteName = "All Tests";

    if (argvIndex < argc) {
        testSuiteName = argv[argvIndex];
        argvIndex++;
    }

    printf("\n\n=== SFLphone initialization ===\n\n");
    backup();
    ring::Manager::instance().init(CONFIG_SAMPLE);

    // Get the top level suite from the registry
    printf("\n\n=== Test Suite: %s ===\n\n", testSuiteName.c_str());
    CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry(testSuiteName).makeTest();

    if (suite->getChildTestCount() == 0) {
        RING_ERR("Invalid test suite name: %s", testSuiteName.c_str());
        restore();
        return 1;
    }

    // Adds the test to the list of test to run
    CppUnit::TextTestRunner runner;
    runner.addTest(suite);
    /* Specify XML output */
    std::ofstream outfile("cppunitresults.xml");

    if (xmlOutput) {
        CppUnit::XmlOutputter* outputter = new CppUnit::XmlOutputter(&runner.result(), outfile);
        runner.setOutputter(outputter);
    } else {
        // Change the default outputter to a compiler error format outputter
        runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr));
    }

    // Run the tests.
    bool wasSuccessful = runner.run();

    printf("=== Test suite ending ===\n");
    ring::Manager::instance().finish();

    restore();

    return wasSuccessful ? 0 : 1;
}
示例#12
0
文件: test.cpp 项目: gdos/wxWidgets
// Run
//
int TestApp::RunTests()
{
#if wxUSE_LOG
    // Switch off logging unless --verbose
    bool verbose = wxLog::GetVerbose();
    wxLog::EnableLogging(verbose);
#else
    bool verbose = false;
#endif

    CppUnit::TextTestRunner runner;

    if ( m_registries.empty() )
    {
        // run or list all tests which use the CPPUNIT_TEST_SUITE_REGISTRATION() macro
        // (i.e. those registered in the "All tests" registry); if there are other
        // tests not registered with the CPPUNIT_TEST_SUITE_REGISTRATION() macro
        // then they won't be listed/run!
        AddTest(runner, TestFactoryRegistry::getRegistry().makeTest());

        if (m_list)
        {
            cout << "\nNote that the list above is not complete as it doesn't include the \n";
            cout << "tests disabled by default.\n";
        }
    }
    else // run only the selected tests
    {
        for (size_t i = 0; i < m_registries.size(); i++)
        {
            const wxString reg = m_registries[i];
            Test *test = GetTestByName(reg);

            if ( !test && !reg.EndsWith("TestCase") )
            {
                test = GetTestByName(reg + "TestCase");
            }

            if ( !test )
            {
                cerr << "No such test suite: " << string(reg.mb_str()) << endl;
                return 2;
            }

            AddTest(runner, test);
        }
    }

    if ( m_list )
        return EXIT_SUCCESS;

    runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), cout));

    // there is a bug
    // (http://sf.net/tracker/index.php?func=detail&aid=1649369&group_id=11795&atid=111795)
    // in some versions of cppunit: they write progress dots to cout (and not
    // cerr) and don't flush it so all the dots appear at once at the end which
    // is not very useful so unbuffer cout to work around this
    cout.setf(ios::unitbuf);

    // add detail listener if needed
    DetailListener detailListener(m_timing);
    if ( m_detail || m_timing )
        runner.eventManager().addListener(&detailListener);

    // finally ensure that we report our own exceptions nicely instead of
    // giving "uncaught exception of unknown type" messages
    runner.eventManager().pushProtector(new wxUnitTestProtector);

    bool printProgress = !(verbose || m_detail || m_timing);
    runner.run("", false, true, printProgress);

    return runner.result().testFailures() == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}