[Cppunit-devel] TestFailure, TestResult and TestListener revision proposal
Brought to you by:
blep
From: Baptiste L. <bl...@cl...> - 2001-09-24 21:35:57
|
When I wrote Qt TestRunner last week, something stroke me as unnecessary complex: TestResult result ! Failure fall in two types: - error: failure, which cause is a catch (...) in either setUp(), runTest() or tearDown(), - failure: failure which cause is CPPUNIT_ASSERT or expected exception not caught (in fact, any exception of type Exception caught in setUp(), runTest() or tearDown() ). Here all is fine. Error indicate a "severity" flag: the application flow is broken by an unexpected exception (or a structure exception on Windows, a crash if you want). The complexity come in the fact that distinction is never stored in TestFailure. Instead, you must rely on the method you override ( addError() or addFailure() in either TestResult or TestListener ). Add to that the fact there is no way to obtain a list of all failure. You need to grab two distincts lists, meaning you got an unordered set of failures. The proposed change are: - add bool TestFailure::isError(); - add void TestResult::failureAdded( TestFailure *failure), called by both TestResult::addFailure() and TestResult::addError(). [Is that one really needed?] - remove std::vector<TestFailure *>& TestResult::errors() - remove TestListener::addError() and TestListener::addFailure() - add TestListener::failureAdded( TestFailure *failure ) - have TestResult::addError() and TestResult::addFailure() adding failure in m_failures. - add TestFailure *TestResult::failureAt( int index ) - something need to be done about int TestResult::testErrors() and int TestResult::testFailures() to avoid confusion. Remove testErrors() and have testFailures() report the number of call to both addError() and addFailure() ? => That make it possible to use TestResult as a model for the list of failures (avoiding some code duplication). => Make it much easier to work with TestResult. Most of the time, you don't care weither it was an error or a failure. So what ? Baptiste. --- Baptiste Lepilleur <gai...@fr...> http://gaiacrtn.free.fr/index.html Author of The Text Reformatter, a tool for fanfiction readers and writers. Language: English, French (Well, I'm French). |