本文整理汇总了C++中Tester::runTestsWithExceptionHandling方法的典型用法代码示例。如果您正苦于以下问题:C++ Tester::runTestsWithExceptionHandling方法的具体用法?C++ Tester::runTestsWithExceptionHandling怎么用?C++ Tester::runTestsWithExceptionHandling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tester
的用法示例。
在下文中一共展示了Tester::runTestsWithExceptionHandling方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, const char * const argv[], char *env[])
{
unsigned int i= 0;
int totalTests = 0, totalPassed = 0, criticalFailures = 0;
int totalDisabled = 0;
bool testerTestIncluded = false;
std::string testnameRegexp = "";
bool disableNegativeTests = false;
bool showall = false;
for (int i = 1; i < argc; i++)
{
std::string arg(argv[i]);
if (arg == "--disable-negative-tests")
{
disableNegativeTests = true;
} else if (arg == "--showall")
{
showall = true;
} else if (testnameRegexp.size() == 0) {
testnameRegexp = arg;
} else {
std::cout << "usage: " << argv[0] << " [--showall] [--disable-negative-tests] [regular-expression]\n";
::exit(1);
}
}
if (testnameRegexp.size() == 0)
testnameRegexp = ".*";
// initialize APR
apr_status_t result;
result = apr_app_initialize(&argc, &argv, 0 /*env*/);
if (result)
NTA_THROW << "error initializing APR. Err code: " << result;
Tester::init(disableNegativeTests); // initialize testinputdir, testoutputdir
std::cout << "Executing tests matching the regular expression \""
<< testnameRegexp << "\"\n";
// Create each test suite
if (regex::match(testnameRegexp, "TesterTest")) {
testerTestIncluded = true;
TestInfo t(std::string("TesterTest"), new TesterTest);
allTesters.push_back(t); // Must be first one
}
/*
* The list of tests is generated automatically by update_app.py, which
* creates addtests.hpp. addtests.hpp instantiates all of the test objects
* and pushed them on allTesters
*/
#include "EverythingAddtests.hpp"
// Run each test in our test suite
std::cout << "Found " << allTesters.size() << " test ";
if (allTesters.size() == 1)
std::cout << "set\n";
else
std::cout << "sets\n";
totalTests = 0;
totalPassed = 0;
std::vector<std::string> hardfailTests;
std::vector< failInfo > criticalfailTests;
for(Testers::iterator iter=allTesters.begin();
iter != allTesters.end(); ++iter)
{
Tester* t = iter->second;
t->setName(iter->first);
t->runTestsWithExceptionHandling();
totalTests += t->testCount();
totalPassed += t->passCount();
totalDisabled += t->disabledCount();
criticalFailures += (t->criticalFailureOccurred()?1:0);
t->report(showall);
if (t->testCount() != t->passCount() + t->disabledCount()) {
if (t->getName() != "TesterTest") {
hardfailTests.push_back(t->getName());
}
}
if (t->criticalFailureOccurred()) {
if (t->getName() != "TesterTest") {
failInfo fi(t->getName(), t->getCriticalFailureMsg());
criticalfailTests.push_back(fi);
}
}
}
if (testerTestIncluded) {
// TesterTests should have exactly 3 failures plus one critical failure.
// We consider these as successes
if (allTesters[0].second->hardFailCount() == 4) totalPassed += 4;
if (allTesters[0].second->criticalFailureOccurred() == true)
criticalFailures--;
else criticalFailures++;
}
// Print out high level summary
//.........这里部分代码省略.........