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
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)
+}
#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)
#define TESTS_H
#include <QObject>
+#include <QtTest/QtTest>
+#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
"create table orders("
"id integer primary key autoincrement,"
"customerid integer not null,"
- "date text"
+ "date text,"
"foreign key(customerid) references customers(id)"
")"
};