本文整理汇总了C++中cppunit_ns::textui::TestRunner::setOutputter方法的典型用法代码示例。如果您正苦于以下问题:C++ TestRunner::setOutputter方法的具体用法?C++ TestRunner::setOutputter怎么用?C++ TestRunner::setOutputter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cppunit_ns::textui::TestRunner
的用法示例。
在下文中一共展示了TestRunner::setOutputter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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;
}
示例2: main
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;
}
示例3: main
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;
}
示例4: main
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;
}
示例5: main
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;
}
示例6: main
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;
}
示例7: _CppUnit_RunAllTests_ByName
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;
}