PDA

View Full Version : Misunderstanding QTestLib's TestCase term



lyuts
12th July 2010, 19:47
Hello, guys.

I was just developing unit tests for my application and got really confused about what is "test case" in terms of QTestLib. I need some initialization to be done before each test runs, so I explored docs in Qt Assistant and found initTestCase() slot. So I just had to override it. But I was surprised to see that this slot is called only once. I read QTestLib docs once again and found this:



initTestCase() will be called before the first testfunction is executed.
cleanupTestCase() will be called after the last testfunction was executed.
init() will be called before each testfunction is executed.
cleanup() will be called after every testfunction.


This confused me greatly. As far as I understand (at least it seemed to me that I understood that right) there is "test suite" which is a set of test cases (wikipedia and cppunit told me the same). It should make sense that there should be something like initTestSuite and initTestCase (the same with cleanup).
As it appears in Qt:

Qt's initTestCase corresponds to theory's initTestSuite and
Qt's init corresponds to theory's initTestCase.

I don't understand why these terms are rearanged in Qt.
Doesn't this look a little bit wrong to you? Maybe someone knows the reason for this?

wysota
12th July 2010, 22:29
What if you interpret "initTestCase" as "test case which performs initialization"?

Actually a "test suite" in terms of QtTestLib is a set of separate executables each performing a separate test composed from many test cases. That's my guess at least.

lyuts
13th July 2010, 08:10
What if you interpret "initTestCase" as "test case which performs initialization"?
I do treat it that way, but many of us will expect it to perform this initialization before each function.


Actually a "test suite" in terms of QtTestLib is a set of separate executables each performing a separate test composed from many >>test cases<<. That's my guess at least.

See, you also think of a test case as a one test function which is included in some set. :)

wysota, were not you confused when you read the description of initTestCase, init, etc.?

wysota
13th July 2010, 10:09
wysota, were not you confused when you read the description of initTestCase, init, etc.?
No, I have read the documentation (and have seen a presentation on test lib) before I started coding my own tests.

lyuts
13th July 2010, 11:34
Ok, I got your point of view.