QtTest conventions

Manuel Breugelmans mbr.nxi at gmail.com
Wed Apr 23 15:20:55 UTC 2008


On Wednesday 23 April 2008 14:22:48 Andreas Pakulat wrote:
> > * test commands are prefixed with 'test'
>
> If you're talking about the functions that contain the actual tests than
> I disagree about this one. I'd like to not have test in there as its
> completely redundant - at least for QtTest unittests. All slots in that
> class are tests automatically and are automatically run by QtTest.

I'm fine with either, the majority of the existing kdev test commands 
have 'test' prefixed though. On the other hand, newer frameworks (JUnit4) 
abandon it indeed. CppUnit, PyUnit and JUnit3 still require or recommend it.

The biggest pro for keeping such a naming convention for QtTests is 
readability. Especially in larger testcases the distinction between a command 
and a helper might fade. The slots 'annotation' is only available in the 
header, so not directly obvious. This is indeed only a tiny plus, possibly 
outweighted by the redundancy.

> > * fixture methods {init,cleanup}TestCase declared first
>
> I think thats just because you need them before you can execute a test.
> I don't think there should be a policy where to put the functions.

I meant in the class declaration.

preferred:

class FooTest : ...
{
private slots:
	initTestCase();
	cleanupTestCase();

	[test]Foo();
};

over:

class FooTest : ...
{
private slots:
	[test]Foo();
	cleanupTestCase();
	[test]Bar();
	initTestCase();
};


> > * helper methods and fixture attributes declared private in the testcase
>
> Only if they're specific to that testcase, else they should be in a file
> thats used by all tests
>
> Andreas


Manuel




More information about the KDevelop-devel mailing list