From 33792c4fcfc1a74060fb9a3165f357e39514753c Mon Sep 17 00:00:00 2001 From: John Janus Date: Mon, 12 Jun 2017 23:15:54 +0200 Subject: [PATCH] fix tests setup and a typo --- CleaningService.pro | 22 ++++++++++++++++------ Tests/tests.cpp | 30 +++++++++++++++++++++++++++++- Tests/tests.h | 14 ++++++++++++-- dbconn.h | 2 +- 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/CleaningService.pro b/CleaningService.pro index b35ca2b..eeb5607 100644 --- a/CleaningService.pro +++ b/CleaningService.pro @@ -1,12 +1,11 @@ TEMPLATE = app -QT += qml quick sql testlib -CONFIG += c++11 testcase +QT += qml quick sql +CONFIG += c++11 SOURCES += main.cpp \ dbconn.cpp \ - logging.cpp \ - Tests/tests.cpp + logging.cpp RESOURCES += qml.qrc @@ -34,8 +33,19 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin HEADERS += \ dbconn.h \ - logging.h \ - Tests/tests.h + logging.h DISTFILES += \ style.astylerc + +test { + message(Tests) + QT += testlib + TARGET = UnitTests + SOURCES -= main.cpp + SOURCES += Tests/tests.cpp + HEADERS += Tests/tests.h + CONFIG += testcase +} else { + message(NormalBuild) +} diff --git a/Tests/tests.cpp b/Tests/tests.cpp index c493976..e771678 100644 --- a/Tests/tests.cpp +++ b/Tests/tests.cpp @@ -1,6 +1,34 @@ #include "tests.h" -Tests::Tests(QObject *parent) : QObject(parent) +Tests::Tests (QObject* parent) : QObject (parent) { } + +void Tests::initTestCase() +{ + +} + +void Tests::init() +{ + +} + +void Tests::cleanup() +{ + +} + +void Tests::cleanupTestCase() +{ + +} + +void Tests::dbTest() +{ + DbConn db; + QVERIFY (1 == 1); +} + +QTEST_MAIN (Tests) diff --git a/Tests/tests.h b/Tests/tests.h index 53fe24d..a32e800 100644 --- a/Tests/tests.h +++ b/Tests/tests.h @@ -2,16 +2,26 @@ #define TESTS_H #include +#include +#include "../dbconn.h" class Tests : public QObject { Q_OBJECT + public: - explicit Tests(QObject *parent = nullptr); + explicit Tests (QObject* parent = nullptr); signals: public slots: +private slots: + void initTestCase(); //run once before the tests + void init(); //run before every test + void cleanup(); //run after each test + void cleanupTestCase(); //run once after all tests + + void dbTest(); }; -#endif // TESTS_H \ No newline at end of file +#endif // TESTS_H diff --git a/dbconn.h b/dbconn.h index 241f315..d562f6e 100644 --- a/dbconn.h +++ b/dbconn.h @@ -37,7 +37,7 @@ class DbConn : public QObject "create table orders(" "id integer primary key autoincrement," "customerid integer not null," - "date text" + "date text," "foreign key(customerid) references customers(id)" ")" }; -- 2.47.0