[Cppunit-cvs] cppunit2/include/opentest forwards.h,1.2,1.3 texttestdriver.h,1.4,1.5
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2004-11-21 22:28:46
|
Update of /cvsroot/cppunit/cppunit2/include/opentest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27566/include/opentest Modified Files: forwards.h texttestdriver.h Log Message: * added reporting of error and fault Index: texttestdriver.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/opentest/texttestdriver.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** texttestdriver.h 20 Nov 2004 15:07:00 -0000 1.4 --- texttestdriver.h 21 Nov 2004 22:27:15 -0000 1.5 *************** *** 155,158 **** --- 155,162 ---- std::string getTestPath( TestId test, unsigned int maxParent = -1 ) const; + void reportFailure( const TestResult &testResult, + const Properties &failure, + bool isAssertion ); + TestRunner &runner_; /// Information associated to each test/suite at declaration time *************** *** 472,475 **** --- 476,494 ---- const TestResult &testResult = results_.at( *failuresIt ); PropertiesAccessor info = testResult.result().accessor(); + Properties::ValueEnum enumFaults = info["result/faults"].listValues(); + while ( enumFaults.hasNext() ) + { + // @todo check is properties => schema check ? + Value fault = enumFaults.next(); + reportFailure( testResult, fault.asProperties(), false ); + } + Properties::ValueEnum enumAssertions = info["result/assertions"].listValues(); + while ( enumAssertions.hasNext() ) + { + // @todo check is properties => schema check ? + Value assertion = enumAssertions.next(); + reportFailure( testResult, assertion.asProperties(), true ); + } + /* PropertiesAccessor locationInfo = info["result"]["status"]["location"]; if ( locationInfo.isValid() ) *************** *** 492,495 **** --- 511,515 ---- if ( !message.empty() ) std::cout << message << std::endl; + */ std::cout << "Failures: " << failures_.size() << ", "; *************** *** 499,502 **** --- 519,566 ---- + inline void + TextTestDriver::reportFailure( const TestResult &testResult, + const Properties &failure, + bool isAssertion ) + { + if ( failure.has( "location") ) + { + if ( failure.has("location/file") ) + { + std::cout << failure["location/file"].asString() << "(" + << failure["location/line"].asInt() << ") "; + } + if ( failure.has("location/function") ) + std::cout << "{" << failure["location/function"].asString() << "} "; + std::cout << " : "; + } + + std::cout << getTestPath( testResult.test() ) << std::endl; + + std::string failureType = failure.getValue( "failure_type", + isAssertion ? "assertion" + : "fault" ).asString(); + std::cout << "Failure type : " << failureType << std::endl; + Properties::ValueEnum enumMessages = failure.accessor()["messages"].listValues(); + if ( enumMessages.hasNext() ) + std::cout << "Messages:\n"; + while ( enumMessages.hasNext() ) + { // @todo check type + std::string message = enumMessages.next().asString(); + std::cout << message << std::endl; + } + + Properties::ValueEnum enumLogs = failure.accessor()["logs"].listValues(); + if ( enumLogs.hasNext() ) + std::cout << "Log:\n"; + while ( enumLogs.hasNext() ) + { // @todo check type + std::string log = enumLogs.next().asString(); + std::cout << log << std::endl; + } + + std::cout << "Failure tree:" << failure.toString() << std::endl; + } + inline std::string TextTestDriver::getTestPath( TestId test, unsigned int maxParent ) const Index: forwards.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/opentest/forwards.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** forwards.h 19 Nov 2004 19:31:38 -0000 1.2 --- forwards.h 21 Nov 2004 22:27:15 -0000 1.3 *************** *** 8,15 **** namespace OpenTest { - class ConstPropertiesAccessor; class Property; class PropertyPath; class Properties; class ResourceList; class TestDeclarator; --- 8,15 ---- namespace OpenTest { class Property; class PropertyPath; class Properties; + class PropertiesAccessor; class ResourceList; class TestDeclarator; |