Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, October 2006
using Qt unit test framework


Message 1 in thread

Hi !

I'm trying to use, with Qt4.2.0 the unit test framework.

So far, I've been able for my project to write a test class for a call (for 
exemple the class testMyClass for the class MyClass), which has some slots 
for tests. With this, I get a test suite, and I can make it work by adding 
at the end of the file :
QTEST_MAIN(testJSNCCode)

#include "testMyClass.moc"


But now, I'd like to write another test suite for another class, but if I 
add the macro QTEST_MAIN(), the compiler is complaining that there is 
several main() in my app (which make sense to me). But, how can I have 
several test suites, and run all of them ?

Thanks for your help,
Jerome 


--
 [ signature omitted ] 

Message 2 in thread

Can't you just keep the test suites in separate projects?
(i.e. one .pro file (and executable) for each test-suite)

Normally, you want to avoid having all tests execute in the same process 
anyway, since it means that if one test crashes, you won't know the 
result of the remainig 'test suites'.

Usually, it makes sense to have one executable per class you test.

-- 
 [ signature omitted ] 

Message 3 in thread

Jan-Arve Sæther wrote:
> Can't you just keep the test suites in separate projects?
> (i.e. one .pro file (and executable) for each test-suite)
> 
> Normally, you want to avoid having all tests execute in the same process
> anyway, since it means that if one test crashes, you won't know the
> result of the remainig 'test suites'.
> 
> Usually, it makes sense to have one executable per class you test.
> 

Is this really the way the Qt unit test framework should be used? I was
thinking of switching over from CppUnit, but I would find it very
inconvenient to work like this... I want all my tests in the same
executable (which is run after each build so I always know if I broke
something); my tests usually don't crash, but fail---and in the end I
get informed that x of y tests did not pass.

Best,
M

--
 [ signature omitted ] 

Message 4 in thread

On 10/4/06, Martin <martin.umgeher@xxxxxxxxxxx> wrote:
> Is this really the way the Qt unit test framework should be used? I was
> thinking of switching over from CppUnit, but I would find it very
> inconvenient to work like this... I want all my tests in the same
> executable (which is run after each build so I always know if I broke
> something); my tests usually don't crash, but fail---and in the end I
> get informed that x of y tests did not pass.

Qt doesn't have "suite"-possibilities yet.

Someone posted a nice script that I'm using that run all executables
and puts information together.

https://svn.qgis.org/trac/browser/trunk/qgis/tests/src/runtests.sh

-- 
 [ signature omitted ] 

Message 5 in thread

On Wednesday 04 October 2006 16:49, Martin wrote:
> Is this really the way the Qt unit test framework should be used? I was
> thinking of switching over from CppUnit, but I would find it very
> inconvenient to work like this... I want all my tests in the same
> executable (which is run after each build so I always know if I broke
> something); my tests usually don't crash, but fail---and in the end I
> get informed that x of y tests did not pass.

hi,

(i haven't followed the discusion)
just want to say that if you want to switch to something you can try 
boost.test  ( www.boost.org ). It's very flexible and I, personally, am 
really happy with it. 

I guess Qt's unit test framework is most usefull for GUI class testing but i 
haven't felt the need to test GUI classes yet. 


-- 
 [ signature omitted ] 

Attachment: pgpEsyaKchcSM.pgp
Description: PGP signature