清理废弃模块并完善测试基础设施
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#include "TestHarness.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QStandardPaths>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <exception>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QStandardPaths::setTestModeEnabled(true);
|
||||
QCoreApplication application(argc, argv);
|
||||
QCoreApplication::setOrganizationName(QStringLiteral("QtDesktopPetInternalQA"));
|
||||
QCoreApplication::setApplicationName(QStringLiteral("CoreLogicTests"));
|
||||
|
||||
QTextStream output(stdout);
|
||||
QTextStream errors(stderr);
|
||||
int failedCount = 0;
|
||||
|
||||
for (const Qa::TestCase &test : Qa::registry())
|
||||
{
|
||||
try
|
||||
{
|
||||
test.function();
|
||||
output << "[PASS] " << QString::fromStdString(test.name) << Qt::endl;
|
||||
}
|
||||
catch (const std::exception &exception)
|
||||
{
|
||||
++failedCount;
|
||||
errors << "[FAIL] " << QString::fromStdString(test.name)
|
||||
<< ": " << exception.what() << Qt::endl;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
++failedCount;
|
||||
errors << "[FAIL] " << QString::fromStdString(test.name)
|
||||
<< ": unknown exception" << Qt::endl;
|
||||
}
|
||||
}
|
||||
|
||||
output << "Executed " << Qa::registry().size() << " tests; "
|
||||
<< failedCount << " failed." << Qt::endl;
|
||||
return failedCount == 0 ? 0 : 1;
|
||||
}
|
||||
Reference in New Issue
Block a user