commit cca98131743d4bd8bb2ee77e59387f8af53afa0e
Author: Christian Ehringfeld <c.ehringfeld@t-online.de>
Date:   Fri Dec 4 02:05:28 2015 +0100

    test organisation

diff --git a/tests/em/em.pro b/tests/em/em.pro
index c3fb61f..e056866 100644
--- a/tests/em/em.pro
+++ b/tests/em/em.pro
@@ -17,9 +17,12 @@ TEMPLATE = app
 
 
 SOURCES += tst_em.cpp \
-    tst_querybuildertest.cpp \
-    ../models.cpp
+    ../models.cpp \
+    main.cpp \
+    tst_querybuilder.cpp
 DEFINES += SRCDIR=\\\"$$PWD/\\\"
 
 HEADERS += \
-    ../models.h
+    ../models.h \
+    tst_em.h \
+    tst_querybuilder.h
diff --git a/tests/em/main.cpp b/tests/em/main.cpp
new file mode 100644
index 0000000..073901b
--- /dev/null
+++ b/tests/em/main.cpp
@@ -0,0 +1,10 @@
+#include <QtTest>
+#include "tst_em.h"
+#include "tst_querybuilder.h"
+
+int main(int argc, char** argv) {
+    EmTest em;
+    QuerybuilderTest queryBuilderTest;
+    return QTest::qExec(&em, argc, argv) |
+           QTest::qExec(&queryBuilderTest, argc, argv);
+}
diff --git a/tests/em/tst_em.cpp b/tests/em/tst_em.cpp
index cb920be..67ef1b5 100644
--- a/tests/em/tst_em.cpp
+++ b/tests/em/tst_em.cpp
@@ -1,44 +1,6 @@
-#include <QString>
-#include <QtTest>
-#include <QSqlIndex>
-#include "entitymanager.h"
-#include "databasemigration.h"
-#include "../models.h"
-class Em : public QObject {
-    Q_OBJECT
+#include "tst_em.h"
 
-  public:
-    Em();
-
-  private Q_SLOTS:
-    void initTestCase();
-    void cleanupTestCase();
-    void testCheckDuplicates();
-    void testBasics();
-    void init();
-    void cleanup();
-    void testFindById();
-    void testFindId();
-    void testHasChanged();
-    void testValidate();
-    void testRelations();
-    void testRelationTableCreation();
-    void testInheritedRelations();
-    void testDatabaseMigrationTable();
-    void testTableCreation();
-
-  private:
-    CuteEntityManager::EntityManager *e;
-    void createRelationTables();
-    void deleteRelationTables();
-    void containsColumn(QHash<QString, QSharedPointer<QSqlField>> &columns, QString name,
-                        QVariant::Type type = QVariant::UserType, QString tableName = "", bool pk = false);
-};
-
-Em::Em() {
-}
-
-void Em::initTestCase() {
+void EmTest::initTestCase() {
     CuteEntityManager::EntityInstanceFactory::registerClass<Group>();
     CuteEntityManager::EntityInstanceFactory::registerClass<Person>();
     CuteEntityManager::EntityInstanceFactory::registerClass<Article>();
@@ -48,14 +10,14 @@ void Em::initTestCase() {
             ":memory:", "", "", "", "", true, "foreign_keys = ON");
 }
 
-void Em::cleanupTestCase() {
+void EmTest::cleanupTestCase() {
     if (this->e) {
         delete this->e;
         this->e = nullptr;
     }
 }
 
-void Em::testCheckDuplicates() {
+void EmTest::testCheckDuplicates() {
     QSharedPointer<Article> article = QSharedPointer<Article>(new Article(10,
                                       QString("TestItem")));
     QSharedPointer<Entity> entity = article.objectCast<Entity>();
@@ -64,9 +26,7 @@ void Em::testCheckDuplicates() {
     QVERIFY(!this->e->create(copy, true, true));
 }
 
-
-
-void Em::testBasics() {
+void EmTest::testBasics() {
     QSharedPointer<Article> article = QSharedPointer<Article>(new Article(10,
                                       QString("TestItem")));
     QSharedPointer<Entity> entity = article.objectCast<Entity>();
@@ -84,7 +44,7 @@ void Em::testBasics() {
     QCOMPARE(this->e->count("article"), (quint8)0);
 }
 
-void Em::init() {
+void EmTest::init() {
     QStringList inits = QStringList() << "Person" << "Group" << "Article";
     QVERIFY2(this->e->startup("emTestA", inits), "Failure");
     auto migrations = this->e->findAll<CuteEntityManager::DatabaseMigration>();
@@ -92,7 +52,7 @@ void Em::init() {
     QCOMPARE(migrations.at(0)->getVersion(), QString("emTestA"));
 }
 
-void Em::testDatabaseMigrationTable() {
+void EmTest::testDatabaseMigrationTable() {
     auto tables = this->e->getSchema()->getTables();
     QString tblName = "cuteentitymanager::databasemigration";
     bool containsMigration = tables.contains(tblName);
@@ -107,7 +67,7 @@ void Em::testDatabaseMigrationTable() {
     }
 }
 
-void Em::testTableCreation() {
+void EmTest::testTableCreation() {
     auto tables = this->e->getSchema()->getTables();
     bool containsArticle = tables.contains("article");
     QVERIFY(containsArticle);
@@ -158,8 +118,9 @@ void Em::testTableCreation() {
 }
 
 
-void Em::containsColumn(QHash<QString, QSharedPointer<QSqlField>> &columns, QString name,
-                        QVariant::Type type, QString tableName, bool pk) {
+void EmTest::containsColumn(QHash<QString, QSharedPointer<QSqlField>> &columns,
+                            QString name,
+                            QVariant::Type type, QString tableName, bool pk) {
     bool containsColumn = columns.contains(name);
     QVERIFY(containsColumn);
     if(containsColumn) {
@@ -177,7 +138,7 @@ void Em::containsColumn(QHash<QString, QSharedPointer<QSqlField>> &columns, QStr
 }
 
 
-void Em::cleanup() {
+void EmTest::cleanup() {
     auto qb = this->e->getQueryBuilder();
     QVERIFY(this->e->executeQuery(qb->dropTable("person_groups")));
     QVERIFY(this->e->executeQuery(qb->dropTable("group")));
@@ -191,7 +152,7 @@ void Em::cleanup() {
     QVERIFY(this->e->removeAll("cuteentitymanager::databasemigration"));
 }
 
-void Em::testRelationTableCreation() {
+void EmTest::testRelationTableCreation() {
     this->createRelationTables();
     auto tables = this->e->getSchema()->getTables();
     QVERIFY(tables.contains("workergroup"));
@@ -217,7 +178,7 @@ void Em::testRelationTableCreation() {
     this->deleteRelationTables();
 }
 
-void Em::testInheritedRelations() {
+void EmTest::testInheritedRelations() {
     QSharedPointer<Employee> e1 = QSharedPointer<Employee>(new Employee(42, "Fenja", "S.",
                                   Person::Gender::FEMALE, "fenja.jpeg", "", "Lotta", QDate(1990, 10, 10), "Psychology"));
     QSharedPointer<Employee> e2 = QSharedPointer<Employee>(new Employee(11, "Janine",
@@ -242,12 +203,12 @@ void Em::testInheritedRelations() {
     }
 }
 
-void Em::createRelationTables() {
+void EmTest::createRelationTables() {
     QStringList relationTables = QStringList() << "Employee" << "WorkerGroup";
     QVERIFY2(this->e->startup("emTestB", relationTables), "Failure");
 }
 
-void Em::deleteRelationTables() {
+void EmTest::deleteRelationTables() {
     auto qb = this->e->getQueryBuilder();
     QVERIFY(this->e->executeQuery(qb->dropTable("workergroup_workers")));
     QVERIFY(this->e->executeQuery(qb->dropTable("employee")));
@@ -266,7 +227,7 @@ void Em::deleteRelationTables() {
     QCOMPARE(migrations.size(), 1);
 }
 
-void Em::testFindById() {
+void EmTest::testFindById() {
     QSharedPointer<Person> p = QSharedPointer<Person>(new Person("Patrick", "De",
                                Person::Gender::MALE, "patrick.jpeg", "", "Pat", QDate(2000, 1, 1)));
     auto ent = p.objectCast<Entity>();
@@ -276,7 +237,7 @@ void Em::testFindById() {
     QVERIFY(this->e->findById(id, p->getClassname()));
 }
 
-void Em::testFindId() {
+void EmTest::testFindId() {
     QSharedPointer<Person> p = QSharedPointer<Person>(new Person("Essi", "Sa",
                                Person::Gender::MALE, "essi.jpeg", "", "Essi", QDate(2000, 1, 1)));
     auto ent = p.objectCast<Entity>();
@@ -286,7 +247,7 @@ void Em::testFindId() {
     QVERIFY(foundId  > -1 && foundId == ent->getId());
 }
 
-void Em::testHasChanged() {
+void EmTest::testHasChanged() {
     QSharedPointer<Person> p = QSharedPointer<Person>(new Person("Jelena", "Fl",
                                Person::Gender::MALE, "max.jpeg", "", "Maxi", QDate(2000, 1, 1)));
     auto ent = p.objectCast<Entity>();
@@ -297,7 +258,7 @@ void Em::testHasChanged() {
     QVERIFY(this->e->hasChanged(ent));
 }
 
-void Em::testValidate() {
+void EmTest::testValidate() {
     QSharedPointer<Person> p = QSharedPointer<Person>(new Person("Patrick", "Pe",
                                Person::Gender::MALE, "patrick2.jpeg", "", "Maxi", QDate(2000, 1, 1)));
     auto ent = p.objectCast<Entity>();
@@ -308,7 +269,7 @@ void Em::testValidate() {
     QVERIFY(!this->e->validate(ent) && ent->getErrors().size() == 2);
 }
 
-void Em::testRelations() {
+void EmTest::testRelations() {
     QSharedPointer<Person> p1 = QSharedPointer<Person>(new Person("Lucien", "We",
                                 Person::Gender::MALE, "lucien.jpeg", "", "Luc", QDate(2000, 1, 1)));
     QSharedPointer<Person> p2 = QSharedPointer<Person>(new Person("Janine", "Musterfrau",
@@ -342,7 +303,3 @@ void Em::testRelations() {
     this->e->refresh(entityFp);
     QVERIFY(firstPerson->getGroups().size() == 0 && g->getPersons().size() == 1);
 }
-
-QTEST_APPLESS_MAIN(Em)
-
-#include "tst_em.moc"
diff --git a/tests/em/tst_em.h b/tests/em/tst_em.h
new file mode 100644
index 0000000..53cd490
--- /dev/null
+++ b/tests/em/tst_em.h
@@ -0,0 +1,38 @@
+#ifndef TST_EM
+#define TST_EM
+#include <QString>
+#include <QtTest>
+#include <QSqlIndex>
+#include "entitymanager.h"
+#include "databasemigration.h"
+#include "../models.h"
+
+class EmTest : public QObject {
+    Q_OBJECT
+
+  private Q_SLOTS:
+    void initTestCase();
+    void cleanupTestCase();
+    void testCheckDuplicates();
+    void testBasics();
+    void init();
+    void cleanup();
+    void testFindById();
+    void testFindId();
+    void testHasChanged();
+    void testValidate();
+    void testRelations();
+    void testRelationTableCreation();
+    void testInheritedRelations();
+    void testDatabaseMigrationTable();
+    void testTableCreation();
+
+  private:
+    CuteEntityManager::EntityManager *e;
+    void createRelationTables();
+    void deleteRelationTables();
+    void containsColumn(QHash<QString, QSharedPointer<QSqlField>> &columns, QString name,
+                        QVariant::Type type = QVariant::UserType, QString tableName = "", bool pk = false);
+};
+#endif // TST_EM
+
diff --git a/tests/em/tst_querybuilder.cpp b/tests/em/tst_querybuilder.cpp
new file mode 100644
index 0000000..1edb665
--- /dev/null
+++ b/tests/em/tst_querybuilder.cpp
@@ -0,0 +1,147 @@
+#include "tst_querybuilder.h"
+
+void QuerybuilderTest::initTestCase() {
+    CuteEntityManager::EntityInstanceFactory::registerClass<Group>();
+    CuteEntityManager::EntityInstanceFactory::registerClass<Person>();
+    CuteEntityManager::EntityInstanceFactory::registerClass<Article>();
+    CuteEntityManager::EntityInstanceFactory::registerClass<Employee>();
+    CuteEntityManager::EntityInstanceFactory::registerClass<WorkerGroup>();
+    this->e = new CuteEntityManager::EntityManager("QSQLITE",
+            ":memory:", "", "", "", "", true, "foreign_keys = ON");
+    QStringList inits = QStringList() << "Person" << "Group" << "Employee" << "WorkerGroup";
+    QVERIFY2(this->e->startup("queryBuilderTest", inits), "Failure");
+    QSharedPointer<Person> p1 = QSharedPointer<Person>(new Person("Lucien", "We",
+                                Person::Gender::MALE, "lucien.jpeg", "", "Luc", QDate(1995, 2, 4)));
+    QSharedPointer<Employee> p2 = QSharedPointer<Employee>(new Employee(11, "Janine",
+                                  "Musterfrau",
+                                  Person::Gender::FEMALE, "janine.jpeg", "", "", QDate(1992, 8, 5), "B"));
+    QSharedPointer<Employee> p3 = QSharedPointer<Employee>(new Employee(42, "Fenja", "Sey.",
+                                  Person::Gender::FEMALE, "fenja.jpeg", "", "Lotta", QDate(1990, 11, 11), "A"));
+    QSharedPointer<Person> p4 = QSharedPointer<Person>(new Person("Fenja", "Neu",
+                                Person::Gender::FEMALE, "fenja2.jpeg", "", "Fenni", QDate(1980, 5, 30)));
+    QSharedPointer<Group> g = QSharedPointer<Group>(new Group("Group Psy"));
+    QSharedPointer<Group> g2 = QSharedPointer<Group>(new Group("Group Health"));
+    g->setLeader(p1);
+    g->setPersons({p1, p2, p4});
+    g2->setLeader(p3);
+    g2->setPersons({p3});
+    QSharedPointer<WorkerGroup> wg = QSharedPointer<WorkerGroup>(new
+                                     WorkerGroup("Taskforce P&H", 50));
+    wg->addWorker(p2);
+    wg->addWorker(p3);
+    auto gEnt = g.objectCast<Entity>();
+    auto g2Ent = g2.objectCast<Entity>();
+    auto wgEnt = wg.objectCast<Entity>();
+    try {
+        QVERIFY(this->e->save(gEnt));
+        QVERIFY(this->e->save(wgEnt));
+        QVERIFY(this->e->save(g2Ent));
+    } catch(QString s) {
+        QFAIL(s.toUtf8().constData());
+    }
+}
+
+void QuerybuilderTest::cleanupTestCase() {
+    auto qb = this->e->getQueryBuilder();
+    QVERIFY(this->e->executeQuery(qb->dropTable("workergroup_workers")));
+    QVERIFY(this->e->executeQuery(qb->dropTable("employee")));
+    QVERIFY(this->e->executeQuery(qb->dropTable("workergroup")));
+    QVERIFY(this->e->executeQuery(qb->dropTable("person_groups")));
+    QVERIFY(this->e->executeQuery(qb->dropTable("group")));
+    QVERIFY(this->e->executeQuery(qb->dropTable("person")));
+    QVERIFY(this->e->removeAll("cuteentitymanager::databasemigration"));
+    if (this->e) {
+        delete this->e;
+        this->e = nullptr;
+    }
+}
+
+void QuerybuilderTest::testFindByAttributes() {
+    QHash<QString, QVariant> attributes;
+    attributes["persNumber"] = 42;
+    QSharedPointer<Employee> p = e->findEntityByAttributes<Employee>(attributes, true);
+    QVERIFY(p);
+    QCOMPARE(p->getNickName(), QString("Lotta"));
+}
+
+void QuerybuilderTest::testFindByAttributesManyToOneRelation() {
+    QHash<QString, QVariant> attributes;
+    attributes["firstName"] = QString("Lucien");
+    attributes["familyName"] = QString("We");
+    QSharedPointer<Person> p = e->findEntityByAttributes<Person>(attributes, true);
+    QVERIFY(p);
+    attributes.clear();
+    attributes["leader"] = QVariant(p);
+    QSharedPointer<Group> group = e->findEntityByAttributes<Group>
+                                  (attributes, true);
+    QVERIFY(group);
+    QCOMPARE(group->getName(), QString("Group Psy"));
+}
+
+void QuerybuilderTest::testFindByAttributesManyToOneRelationAttribute() {
+    QHash<QString, QVariant> attributes;
+    attributes["leader.firstName"] = QString("Fenja");
+    QSharedPointer<Group> group = e->findEntityByAttributes<Group>
+                                  (attributes, true);
+    QVERIFY(group);
+}
+
+void QuerybuilderTest::testFindByAttributesManyToManyRelation() {
+    QHash<QString, QVariant> attributes;
+    attributes["persNumber"] = 42;
+    QSharedPointer<Person> p = e->findEntityByAttributes<Person>(attributes, true);
+    QVERIFY(p);
+    QCOMPARE(p->getNickName(), QString("Lotta"));
+    attributes.clear();
+    attributes["persons"] = QVariant(p);
+    QSharedPointer<Group> group = e->findEntityByAttributes<Group>
+                                  (attributes, true);
+    QVERIFY(group);
+    QCOMPARE(group->getName(), QString("Group Health"));
+}
+
+void QuerybuilderTest::testFindByAttributesManyToManyRelationWithList() {
+    QHash<QString, QVariant> attributes;
+    QList<QSharedPointer<Person>> persons = QList<QSharedPointer<Person>>();
+    attributes["firstName"] = QString("Lucien");
+    QSharedPointer<Person> p1 = e->findEntityByAttributes<Person>(attributes, true);
+    QVERIFY(p1);
+    QCOMPARE(p1->getFamilyName(), QString("We"));
+    persons.append(p1);
+    attributes["firstName"] = QString("Janine");
+    QSharedPointer<Person> p2 = e->findEntityByAttributes<Person>(attributes, true);
+    QVERIFY(p2);
+    QCOMPARE(p2->getFamilyName(), QString("Musterfrau"));
+    persons.append(p2);
+    attributes.clear();
+    QVariant var;
+    var.setValue<QList<QSharedPointer<Person>>>(persons);
+    attributes["persons"] = var;
+    QSharedPointer<Group> group = e->findEntityByAttributes<Group>
+                                  (attributes, true);
+    QVERIFY(group);
+    QCOMPARE(group->getName(), QString("Group Psy"));
+}
+
+void QuerybuilderTest::testFindByAttributesManyToManyRelationAttribute() {
+    QHash<QString, QVariant> attributes;
+    attributes["persons.firstName"] = QString("Janine");
+    QSharedPointer<Group> group = e->findEntityByAttributes<Group>
+                                  (attributes, true);
+    QVERIFY(group);
+    QCOMPARE(group->getName(), QString("Group Psy"));
+}
+
+void QuerybuilderTest::testQueryBuilder() {
+//    Query q = Query();
+//    q.appendWhere(e->getQueryBuilder()->like(QString("firstname"), QString("Tim"),
+//                  JokerPosition::BEHIND));
+//    q.appendWhere(e->getQueryBuilder()->andOperator());
+//    q.appendWhere(e->getQueryBuilder()->arbitraryOperator("<", "birthday",
+//                  QDate(2000, 10, 10)));
+//    //q.appendJoin(Join("person", "pupil.id = person.id"));
+//    q.setDistinct(true);
+//    q.appendOrderBy(OrderBy(QString("birthday"), Direction::SORT_DESC));
+//    q.setLimit(10);
+    //    QList<QSharedPointer<Pupil>> list = e->find<Pupil>(q, true);
+}
diff --git a/tests/em/tst_querybuilder.h b/tests/em/tst_querybuilder.h
new file mode 100644
index 0000000..94053c6
--- /dev/null
+++ b/tests/em/tst_querybuilder.h
@@ -0,0 +1,26 @@
+#ifndef TST_QUERYBUILDER
+#define TST_QUERYBUILDER
+#include <QString>
+#include <QtTest>
+#include "entitymanager.h"
+#include "databasemigration.h"
+#include "../models.h"
+
+class QuerybuilderTest : public QObject {
+    Q_OBJECT
+
+  private Q_SLOTS:
+    void initTestCase();
+    void cleanupTestCase();
+    void testFindByAttributes();
+    void testFindByAttributesManyToOneRelation();
+    void testFindByAttributesManyToOneRelationAttribute();
+    void testFindByAttributesManyToManyRelation();
+    void testFindByAttributesManyToManyRelationWithList();
+    void testFindByAttributesManyToManyRelationAttribute();
+    void testQueryBuilder();
+  private:
+    CuteEntityManager::EntityManager *e;
+};
+#endif // TST_QUERYBUILDER
+
diff --git a/tests/em/tst_querybuildertest.cpp b/tests/em/tst_querybuildertest.cpp
deleted file mode 100644
index 6ce3af0..0000000
--- a/tests/em/tst_querybuildertest.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-#include <QString>
-#include <QtTest>
-#include "entitymanager.h"
-#include "databasemigration.h"
-#include "../models.h"
-
-class QuerybuilderTest : public QObject {
-    Q_OBJECT
-
-  public:
-    QuerybuilderTest();
-
-  private Q_SLOTS:
-    void initTestCase();
-    void cleanupTestCase();
-    void testFindByAttributes();
-    void testFindByAttributesManyToOneRelation();
-    void testFindByAttributesManyToOneRelationAttribute();
-    void testFindByAttributesManyToManyRelation();
-    void testFindByAttributesManyToManyRelationAttribute();
-    void testFindByAttributesInheritance();
-    void testQueryBuilder();
-    void testQueryBuilderInheritance();
-  private:
-    CuteEntityManager::EntityManager *e;
-};
-
-QuerybuilderTest::QuerybuilderTest() {
-}
-
-void QuerybuilderTest::initTestCase() {
-    CuteEntityManager::EntityInstanceFactory::registerClass<Group>();
-    CuteEntityManager::EntityInstanceFactory::registerClass<Person>();
-    CuteEntityManager::EntityInstanceFactory::registerClass<Article>();
-    CuteEntityManager::EntityInstanceFactory::registerClass<Employee>();
-    CuteEntityManager::EntityInstanceFactory::registerClass<WorkerGroup>();
-    this->e = new CuteEntityManager::EntityManager("QSQLITE",
-            ":memory:", "", "", "", "", true, "foreign_keys = ON");
-    QStringList inits = QStringList() << "Person" << "Group" << "Employee" << "WorkerGroup";
-    QVERIFY2(this->e->startup("queryBuilderTest", inits), "Failure");
-    QSharedPointer<Person> p1 = QSharedPointer<Person>(new Person("Lucien", "We",
-                                Person::Gender::MALE, "lucien.jpeg", "", "Luc", QDate(1995, 2, 4)));
-    QSharedPointer<Employee> p2 = QSharedPointer<Employee>(new Employee(11, "Janine",
-                                  "Musterfrau",
-                                  Person::Gender::FEMALE, "janine.jpeg", "", "", QDate(1992, 8, 5), "B"));
-    QSharedPointer<Employee> p3 = QSharedPointer<Employee>(new Employee(42, "Fenja", "Sey.",
-                                  Person::Gender::FEMALE, "fenja.jpeg", "", "Lotta", QDate(1990, 11, 11), "A"));
-    QSharedPointer<Person> p4 = QSharedPointer<Person>(new Person("Fenja", "Neu",
-                                Person::Gender::FEMALE, "fenja2.jpeg", "", "Fenni", QDate(1980, 5, 30)));
-    QSharedPointer<Group> g = QSharedPointer<Group>(new Group("Group Psy"));
-    QSharedPointer<Group> g2 = QSharedPointer<Group>(new Group("Group Health"));
-    g->setLeader(p1);
-    g->setPersons({p1, p2, p4});
-    g->setLeader(p3);
-    g->setPersons({p3});
-    QSharedPointer<WorkerGroup> wg = QSharedPointer<WorkerGroup>(new
-                                     WorkerGroup("Taskforce P&H", 50));
-    wg->addWorker(p2);
-    wg->addWorker(p3);
-    auto gEnt = g.objectCast<Entity>();
-    auto g2Ent = g2.objectCast<Entity>();
-    auto wgEnt = wg.objectCast<Entity>();
-    QVERIFY(this->e->save(gEnt));
-    QVERIFY(this->e->save(wgEnt));
-    QVERIFY(this->e->save(g2Ent));
-}
-
-void QuerybuilderTest::cleanupTestCase() {
-    auto qb = this->e->getQueryBuilder();
-    QVERIFY(this->e->executeQuery(qb->dropTable("workergroup_workers")));
-    QVERIFY(this->e->executeQuery(qb->dropTable("employee")));
-    QVERIFY(this->e->executeQuery(qb->dropTable("workergroup")));
-    QVERIFY(this->e->executeQuery(qb->dropTable("person_groups")));
-    QVERIFY(this->e->executeQuery(qb->dropTable("group")));
-    QVERIFY(this->e->executeQuery(qb->dropTable("person")));
-    QVERIFY(this->e->removeAll("cuteentitymanager::databasemigration"));
-    if (this->e) {
-        delete this->e;
-        this->e = nullptr;
-    }
-}
-
-void QuerybuilderTest::testFindByAttributes() {
-    QHash<QString, QVariant> attributes;
-    attributes["persNumber"] = 42;
-    QSharedPointer<Employee> p = e->findEntityByAttributes<Employee>(attributes, true);
-    QVERIFY(p);
-    QCOMPARE(p->getNickName(), QString("Lotta"));
-}
-
-void QuerybuilderTest::testFindByAttributesManyToOneRelation() {
-    QHash<QString, QVariant> attributes;
-    attributes["firstName"] = QString("Lucien");
-    attributes["familyName"] = QString("We");
-    QSharedPointer<Person> p = e->findEntityByAttributes<Person>(attributes, true);
-    QVERFIY(p);
-    attributes.clear();
-    attributes["leader"] = p;
-    QSharedPointer<Group> group = e->findEntityByAttributes<Group>
-                                  (attributes, true);
-    QVERIFY(group);
-    QCOMPARE(group->getName(),QString("Group Psy"));
-}
-
-void QuerybuilderTest::testFindByAttributesManyToOneRelationAttribute() {
-    QHash<QString, QVariant> attributes;
-    attributes["leader.firstName"] = QString("Fenja");
-    QSharedPointer<Group> group = e->findEntityByAttributes<Group>
-                                  (attributes, true);
-    QVERIFY(group);
-}
-
-void QuerybuilderTest::testFindByAttributesManyToManyRelation() {
-    QHash<QString, QVariant> attributes;
-    QList<QSharedPointer<Person>> persons = QList<QSharedPointer<Person>>();
-//    attributes["persons"] = QVariant(persons);
-//    QSharedPointer<Group> group = e->findEntityByAttributes<Group>
-//                                  (attributes, true);
-// QVERIFY(group);
-}
-
-void QuerybuilderTest::testFindByAttributesManyToManyRelationAttribute() {
-    QHash<QString, QVariant> attributes;
-    attributes["persons.firstName"] = QString("Fenja");
-    QSharedPointer<Group> group = e->findEntityByAttributes<Group>
-                                  (attributes, true);
-    QVERIFY(group);
-}
-
-void QuerybuilderTest::testFindByAttributesInheritance() {
-}
-
-void QuerybuilderTest::testQueryBuilder() {
-//    Query q = Query();
-//    q.appendWhere(e->getQueryBuilder()->like(QString("firstname"), QString("Tim"),
-//                  JokerPosition::BEHIND));
-//    q.appendWhere(e->getQueryBuilder()->andOperator());
-//    q.appendWhere(e->getQueryBuilder()->arbitraryOperator("<", "birthday",
-//                  QDate(2000, 10, 10)));
-//    //q.appendJoin(Join("person", "pupil.id = person.id"));
-//    q.setDistinct(true);
-//    q.appendOrderBy(OrderBy(QString("birthday"), Direction::SORT_DESC));
-//    q.setLimit(10);
-    //    QList<QSharedPointer<Pupil>> list = e->find<Pupil>(q, true);
-}
-
-void QuerybuilderTest::testQueryBuilderInheritance() {
-}
-
-
-QTESTCASE_H
-//QTEST_APPLESS_MAIN(QuerybuilderTest)
-
-#include "tst_querybuildertest.moc"
diff --git a/tests/validators/main.cpp b/tests/validators/main.cpp
new file mode 100644
index 0000000..156e139
--- /dev/null
+++ b/tests/validators/main.cpp
@@ -0,0 +1,9 @@
+#include <QtTest>
+
+int main(int argc, char** argv) {
+//    EmTest em;
+//    QuerybuilderTest queryBuilderTest;
+//    return QTest::qExec(&em, argc, argv) |
+//           QTest::qExec(&queryBuilderTest, argc, argv);
+    return 0;
+}
diff --git a/tests/validators/tst_validatorstest.cpp b/tests/validators/tst_validatorstest.cpp
index ed9950e..d5a5621 100644
--- a/tests/validators/tst_validatorstest.cpp
+++ b/tests/validators/tst_validatorstest.cpp
@@ -39,6 +39,4 @@ void ValidatorsTest::testCase1()
     QVERIFY2(true, "Failure");
 }
 
-QTEST_APPLESS_MAIN(ValidatorsTest)
-
 #include "tst_validatorstest.moc"
diff --git a/tests/validators/validators.pro b/tests/validators/validators.pro
index 79f5707..015a23e 100644
--- a/tests/validators/validators.pro
+++ b/tests/validators/validators.pro
@@ -15,5 +15,6 @@ CONFIG   -= app_bundle
 TEMPLATE = app
 
 
-SOURCES += tst_validatorstest.cpp
+SOURCES += tst_validatorstest.cpp \
+    main.cpp
 DEFINES += SRCDIR=\\\"$$PWD/\\\"
