45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
#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;
|
|
}
|