PDA

View Full Version : debugging a unit test



Martin Drozdik
20th January 2012, 11:44
Dear all,

I am using Qt Creator 2.2.1 Based on Qt 4.7.3 (32 bit). There, I created a unit test using the File -> New File or Project-> Unit test. When I try to debug the unit test, I get a message in a popup window:

This does not seem to be a "Debug" build.
Setting breakpoints by file name and line number may fail.

And the breakpoints are ignored, even though I specified it to be a debug build in the left lower corner of the QtCreator.

I looked up the topic under http://developer.qt.nokia.com/doc/qt-4.8/qtestlib-manual.html under Building a Test and got this suggestion:

If you are using other build tools, make sure that you add the location of the QTestLib header files to your include path (usually include/QtTest under your Qt installation directory). If you are using a release build of Qt, link your test to the QtTest library. For debug builds, use QtTest_debug.

Please, could you explain me what is meant under use QtTest_debug ? I really have no idea here.

I tired:

QT += QtTest_debug
CONFIG += QtTest_debug

with no effect.

wysota
20th January 2012, 11:56
Dear all,

I am using Qt Creator 2.2.1 Based on Qt 4.7.3 (32 bit). There, I created a unit test using the File -> New File or Project-> Unit test. When I try to debug the unit test, I get a message in a popup window:

This does not seem to be a "Debug" build.
Setting breakpoints by file name and line number may fail.

And the breakpoints are ignored, even though I specified it to be a debug build in the left lower corner of the QtCreator.
You need to explicitly rerun qmake and rebuild your project.




If you are using other build tools, make sure that you add the location of the QTestLib header files to your include path (usually include/QtTest under your Qt installation directory). If you are using a release build of Qt, link your test to the QtTest library. For debug builds, use QtTest_debug.

Please, could you explain me what is meant under use QtTest_debug ? I really have no idea here.

I tired:

QT += QtTest_debug
CONFIG += QtTest_debug

with no effect.

You are not using "other build tools", this applies when you have to manually add linking to QtTest libraries.

Martin Drozdik
20th January 2012, 13:05
Thank you very much! It works!

talkfig
1st June 2012, 01:21
Having the same issue - but, the above "fix" is not working on 4.8.1.

i don't find any reference to QtTest_debug anywhere in the Qt dirs...

ChrisW67
1st June 2012, 01:38
Thanks for your "It doesn't work" post... we'll just guess what you are doing.

The issue in the original post is easily fixed by:

Tell QtCreator you want a debug build
Rerun qmake
Rebuild project