Try/catch for unit test main

This commit is contained in:
Klaus Basan
2018-09-28 20:37:46 +02:00
parent 7c42818f44
commit b92d336d2a
2 changed files with 15 additions and 7 deletions

View File

@@ -14,11 +14,11 @@ TEMPLATE = app
DEPENDPATH += \
. \
$$SourceRoot/src \
$$SourceRoot/tests \
$$SourceRoot/tests
INCLUDEPATH += \
$$SourceRoot/src \
$$SourceRoot/tests \
$$SourceRoot/tests
HEADERS += *.h
SOURCES += *.cpp

View File

@@ -49,8 +49,12 @@ args.append({ "-o", resultsFileName + "_testresults.xml,xml" }); \
#define BLACKTEST_APPLESS_MAIN(TestObject) \
int main(int argc, char *argv[]) \
{ \
BLACKTEST_INIT(TestObject) \
return QTest::qExec(&to, args); \
try { \
BLACKTEST_INIT(TestObject) \
return QTest::qExec(&to, args); \
} catch (...) { \
return EXIT_FAILURE; \
} \
}
//! Implements a main() function that executes all tests in TestObject
@@ -59,9 +63,13 @@ int main(int argc, char *argv[]) \
#define BLACKTEST_MAIN(TestObject) \
int main(int argc, char *argv[]) \
{ \
QCoreApplication app(argc, argv); \
BLACKTEST_INIT(TestObject) \
return QTest::qExec(&to, args); \
try { \
QCoreApplication app(argc, argv); \
BLACKTEST_INIT(TestObject) \
return QTest::qExec(&to, args); \
} catch (...) { \
return EXIT_FAILURE; \
} \
}
//! \endcond