Testing Database with QTest
-
Hello,
I would like to write some QTest for database class, like connecting to database, insert tables , data.... I am beginner in this field and don't have a clue how should I start with it. I read some articles which mostly were about testing GUI. But they did not help me so far. I appreciate someone who could give me further information.
-
I would recomend you have a look at -> voidrealms.com
-
Did u read chapter 16: Unit Testing in the Book: Foundations of Qt Development ?
-
Not related to databases, but the same type of concepts apply to testing as with anything else. Take a look at the tests under
http://kenai.com/projects/mongoviewer/sources/svn/show/bson/trunk/src/test?rev=140
-
Thank you MuhamedAuda for introducing the Book. I have read the UnitTest chapter. The first test I wrote is as following:
@
void TestDBMethods::testConnection(){QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setDatabaseName("test"); db.setHostName("localhost"); db.setUserName("************"); db.setPassword("************"); QVERIFY(db.isValid()); QCOMPARE(db.isOpen(), true);
}
@in the normal case my connection will be established but in this case I got fail by QCOMPARE. Could anyone tell me where my error is?
Question: what are the alternatives for testing the methods of another subproject in my test project?