本文整理汇总了C++中TestResult::addListener方法的典型用法代码示例。如果您正苦于以下问题:C++ TestResult::addListener方法的具体用法?C++ TestResult::addListener怎么用?C++ TestResult::addListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestResult
的用法示例。
在下文中一共展示了TestResult::addListener方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv) {
// Create the event manager and test controller
TestResult controller;
// Add a listener that colllects test result
TestResultCollector result;
controller.addListener(&result);
// Add a listener that print dots as test run.
BriefTestProgressListener progress;
controller.addListener(&progress);
TextUi::TestRunner runner;
TestFactoryRegistry ®istry = TestFactoryRegistry::getRegistry();
runner.addTest(registry.makeTest());
std::cout << std::endl << " === Running Tests " << std::endl;
runner.run(controller);
// Print test in a compiler compatible format.
std::cout << std::endl << " === Test Results" << std::endl;
CompilerOutputter outputter(&result, stdCOut());
outputter.write();
ofstream xmlFile("data/cpptestresults.xml");
XmlOutputter xmlOut(&result, xmlFile);
xmlOut.write();
return result.wasSuccessful() ? 0 : 1;
}
示例2: main
int main(int argc, char **argv) {
// Create the event manager and test controller
TestResult controller;
// Add a listener that collects test result
TestResultCollector result;
controller.addListener(&result);
// Add the top suite to the test runner
TestRunner runner;
runner.addTest(TestFactoryRegistry::getRegistry().makeTest());
// Listen to progress
TestListener *listener;
if (jetbrains::teamcity::underTeamcity()) {
// Add unique flowId parameter if you want to run test processes in parallel
// See http://confluence.jetbrains.net/display/TCD6/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-MessageFlowId
listener = new jetbrains::teamcity::TeamcityProgressListener();
} else {
listener = new BriefTestProgressListener();
}
controller.addListener(listener);
// Run tests
runner.run(controller);
delete listener;
return result.wasSuccessful() ? 0 : 1;
}
示例3: main
int main(int argc, char **argv)
{
// Create the event manager and test controller
TestResult controller;
// Add a listener that collects test result
TestResultCollector result;
controller.addListener(&result);
// Add the top suite to the test runner
TestRunner runner;
runner.addTest(TestFactoryRegistry::getRegistry().makeTest());
// Listen to progress
TestListener *listener;
if (JetBrains::underTeamcity())
{
listener = new JetBrains::TeamcityProgressListener();
}
else
{
listener = new BriefTestProgressListener();
}
controller.addListener(listener);
// Run test
runner.run(controller);
delete listener;
return result.wasSuccessful() ? 0 : 1;
}
示例4: main
int main(int argc, char* argv[])
{
TestOption& option = TestOption::Instance();
//命令行解析测试
if(!option.init(argc,argv))
{
return -1;
}
//设置过滤器
TestFilter filter;
filter.setCondition(option.getFilterString());
TestRegistry::setTestFilter(&filter);
//设置输出方式
TestResult tr;
TextOutputter outputter(&tr);
outputter.setShowMode(option.isShowAll());
tr.addListener(&outputter);
//设置全局环境
AddGlobalTestEnvironment(new TestEnv);
//设置重复执行的次数
TestRegistry::runAllTests(tr, option.getRepeatTimes());
// //ini文件解析测试
// FileParse::parse("StackTest.ut");
// FileParse::close();
//
// //Executor测试
// TestCmdExecutor::execute("groupname_testname1",STEP_PRETEST,FileParse::getTestCmdArray());
return 0;
}
示例5: main
int main(int argc, char *argv[]) {
if(argc < 2) {
printf("Usage: %s <lua plugin file name>\n", argv[0]);
printf("for example: %s mytest.lua\n", argv[0]);
return 0;
}
// load the test case plugin
printf("Loading the plugin... \n");
LuaPluginLoader loader;
TestCase* test = loader.open(argv[1]);
if(test == NULL) {
printf("%s\n", loader.getLastError().c_str());
return 0;
}
// create a test listener to collect the result
ConsoleListener listener(false);
// create a test result and add the listeners
TestResult result;
result.addListener(&listener);
// create a test runner and run the test case
TestRunner runner;
runner.addTest(test);
runner.run(result);
return 0;
}
示例6: main
/*
* Run the test suite, return 0 on success, 1 on error.
*/
int main(void) {
TestResult controller;
TestResultCollector result;
controller.addListener(&result);
BriefTestProgressListener progress;
controller.addListener(&progress);
TestRunner runner;
runner.addTest( TestFactoryRegistry::getRegistry().makeTest() );
runner.run(controller);
CompilerOutputter outputter(&result, std::cerr);
outputter.write();
return result.wasSuccessful() ? 0 : 1;
}
示例7: main
int main(int argc, char** argv)
{
TestResult testresult;
TestResultCollector collectedresults;
BriefTestProgressListener progress;
testresult.addListener(&collectedresults);
testresult.addListener(&progress);
TestRunner testrunner;
testrunner.addTest (TestFactoryRegistry::getRegistry().makeTest());
testrunner.run(testresult);
CompilerOutputter compileroutputter(&collectedresults, std::cerr);
compileroutputter.write();
// Output XML for Jenkins CPPunit plugin
/*ofstream xmlFileOut("cppTestBasicMathResults.xml");
XmlOutputter xmlOut(&collectedresults, xmlFileOut);
xmlOut.write();*/
return collectedresults.wasSuccessful() ? 0 : 1;
}
示例8: main
int main(int argc, char **argv) {
TestResult controller;
TestResultCollector result;
controller.addListener(&result);
BriefTestProgressListener progress;
controller.addListener(&progress);
TestRunner runner;
runner.addTest(TestFactoryRegistry::getRegistry().makeTest());
runner.run(controller);
// compiler output
CompilerOutputter coutputter(&result, stdCOut());
coutputter.write();
// output test result for jenkins
std::ofstream ofs("test_result.xml");
CPPUNIT_NS::XmlOutputter outputter(&result, ofs,"UTF-8");
outputter.write();
return result.wasSuccessful() ? 0 : 1;
}
示例9: runXml
/**
* Runs the unit tests, producing the results in a xml file and printing to the screen.
* @param outputFile Xml file to place output.
* @return 0.
*/
int runXml(string outputFile)
{
TestResult controller;
TestResultCollector result;
controller.addListener(&result);
// BriefTestProgressListener progress;
// controller.addListener( &progress );
TextUi::TestRunner runner;
runner.addTest( TestFactoryRegistry::getRegistry().makeTest() );
runner.run( controller );
ofstream xmlFileOut(outputFile.c_str());
XmlOutputter xmlOut(&result, xmlFileOut);
xmlOut.write();
return 0;
}
示例10: run
virtual void run() {
TestResultCollector collector;
// create a test result and add the listeners
TestResult result;
result.addListener(&collector);
// create a test runner
TestRunner runner;
MyTest test1;
MyTest2 test2;
runner.addTest(&test1);
runner.addTest(&test2);
runner.run(result);
//RTF_TEST_REPORT(Asserter::format("count: %d", collector.failedCount()));
RTF_TEST_CHECK(collector.testCount() == 2, "Checking tests count");
RTF_TEST_CHECK(collector.passedCount() == 1, "Checking passed count");
RTF_TEST_CHECK(collector.failedCount() == 1, "Checking failed count");
}