3

I'm looking for a good tutorial on how to use modeltest to test models based on QAbstractItemModel. I don't know how to interpret debug messages that are displayed.

Also I'm having trouble configuring modeltest project to work with my app in QtCreator. Including the .pri/.pro doesn't work. I get an error saying "No rule to mage target ..". After fixing paths in modeltest/modeltest.pro file it starts to compile. But i get this wierd assertion

ASSERT: "QTest::testLogger" in file c:\ndk_buildrepos\qt-desktop\src\testlib\qtestlog.cpp, line 232

Any ideas why this happens ?


My modeltest folder is located inside my project. I added following line at the end of my *.pro file

include(modeltest/modeltest.pri)

The modeltest.pri file contains the following

load(qttest_p4)
SOURCES         += modeltest/modeltest.cpp modeltest/dynamictreemodel.cpp 
HEADERS         += modeltest/modeltest.h modeltest/dynamictreemodel.h

I modified my code to use modeltest this way

model = new TasksModel(this);
new ModelTest(model, this);
ui->treeView->setModel(model);

TasksModel is my implementation of QAbstractItemModel model. ui->treeView is the widget that displays data.

No other modifications where made while integrating modeltest with my app.

Qt version is 4.7.

  • Analyse the callstack - qtestlog.cpp is certainly not the place where your bug is located, but simply the place where it is sent to the debugger. If you need help with your model, you need to include more code from your sources. – Jens Sep 14 '11 at 14:57
  • Added additional data. Any ideas ? What else would be usefull ? –  Sep 14 '11 at 19:34
  • Ok fixed the problem by commenting out #undef Q_ASSERT #define Q_ASSERT QVERIFY lines in modeltest.cpp –  Sep 15 '11 at 22:57

2 Answers2

1

The reason you are getting this error is because you aren't actually using the ModelTest inside a proper QTestLib test case. If you take a look at /tests/auto/modeltest (where you presumably got the modeltest class in the first place), you can see how to properly construct a test case using the ModelTest.

mbroadst
  • 768
  • 6
  • 8
1

This will sound a little overgeeky - but it is, in fact, what the ModelChecker dev intended for you to do ;) When you hit one of the asserts, go to the point in the code where it is hit and read the comments which are written along with it. The entire thing is extremely heavily commented, and describes what is breaking and likely reasons why. This is by far easiest to do if you run your app through a GUI debugger, such as that included in for example KDevelop, Qt Creator or Visual Studio.

leinir
  • 922
  • 1
  • 6
  • 7
  • Thanks. I'm also trying to configure QtCreator to use modeltest in my project. I modified my question, if You have any ideas please help :) –  Sep 14 '11 at 00:27