QTestlib in qtbase doesn't work properly.
I am trying to test qtmultimedia APIs and for that I am using QTest provided by QT itself.
The location of QTest is qtbase/src/teslib.
I am doing this testing on windows 7.
In qtestcase.cpp class there is a function called qExec() which is required to be called from test class written by me.
If qExec gets a fail result it clears the test case information by deleting it.
But if qExec gets unhandled excepation then qtest will not clear test case information and in this case the test case with problem only will be repeated again and again.
This causes my all test cases fail; in case of one bad test case also.
I found that I can clear the test case in the case of unhandled exception then it works properly.
I think this is a valid problem in QTest.
What exception is being produced? All test cases use the same memory space. If it's something like an access violation or stack overflow, then your memory is corrupted and qExec() can't recover.
Thanks for the reply.
I am testing multiple classes from QT using QTest.
In this I am reading input and output using text files.
I am creating and deleting the object of class for each test case (there can be multiple test cases for each API). So there is no chance of memory corruption.
The problem is in handling the text files data from input files.
For generating the negative test scenario; I introduced problem in input file.
So in this case exception comes from qExec() and test case should fail; which is correct because i introduced the fail scenario.
But remaining test cases for same API and other APIs should not fail.
But qExec() doesn't clear the test case information for failed cases and keeps repeating the same test case for same API and other APIs.
Exceptions can cause stack corruption. Your code is executing the wrong function, which sounds like stack corruption. Can you post the code of the method that throws the exception? Also, if you throw your own exceptions, you should always catch them. Unhandled exceptions are nasty.
Anyway, Qt Test is designed to mark pass/fail only by checking boolean results in QCOMPARE() and QVERIFY() -- it doesn't check exceptions. So, if you want to generate negative test cases, you need to catch your exception and then report that the expected exception was caught.