From 0a810d68d0550ba6f7f28f2e0dfcef691bdca7b4 Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Sun, 16 Jun 2002 16:55:58 +0000 Subject: Release 1. release 1.9.8 * include/cppunit/plugin/TestPlugIn.h: updated documentation. * include/cppunit/tools/XmlDocument.h: updated documentation. * include/cppunit/tools/StringTools.h: * src/cppunit/StringTools.cpp: added split() and wrap() functions. * include/cppunit/CompilerOutputter.h: * src/cppunit/CompilerOutputter.cpp: extracted wrap() and splitMessageIntoLines() to StringTools. * include/cppunit/XmlOutputterHook.h: * src/cppunit/XmlOutputterHook.cpp: removed rooNode parameter from beginDocument() and endDocument(). It can be retreive from document. Renamed 'node' occurences to 'element'. * include/cppunit/XmlOutputter.h: * src/cppunit/XmlOutputter.cpp: updated against XmlOutputterHook changes. Renamed 'node' occurences to 'element'. * examples/ClockerPlugIn/ClockerXmlHook.h: * examples/ClockerPlugIn/ClockerXmlHook.cpp: updated against XmlOutputterHook changes. * examples/cppunittest/XmlElementTest.h: * examples/cppunittest/XmlElementTest.cpp: Renamed 'node' occurences to 'element'. * examples/cppunittest/XmlOutputterTest.cpp: updated against XmlOutputterHook changes. * examples/cppunittest/StringToolsTest.h: * examples/cppunittest/StringToolsTest.cpp: added. Unit tests for StringTools. Turn out that VC++ dismiss empty lines in tools output, which is the reason why empty lines where not printed in CompilerOutputter. --- src/cppunit/XmlOutputter.cpp | 63 ++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 32 deletions(-) (limited to 'src/cppunit/XmlOutputter.cpp') diff --git a/src/cppunit/XmlOutputter.cpp b/src/cppunit/XmlOutputter.cpp index 9fc59f7..a1c4345 100644 --- a/src/cppunit/XmlOutputter.cpp +++ b/src/cppunit/XmlOutputter.cpp @@ -57,7 +57,7 @@ XmlOutputter::removeHook( XmlOutputterHook *hook ) void XmlOutputter::write() { - m_xml->setRootElement( makeRootNode() ); + setRootNode(); m_stream << m_xml->toString(); } @@ -69,13 +69,14 @@ XmlOutputter::setStyleSheet( const std::string &styleSheet ) } -XmlElement * -XmlOutputter::makeRootNode() +void +XmlOutputter::setRootNode() { XmlElement *rootNode = new XmlElement( "TestRun" ); + m_xml->setRootElement( rootNode ); for ( Hooks::const_iterator it = m_hooks.begin(); it != m_hooks.end(); ++it ) - (*it)->beginDocument( m_xml, rootNode ); + (*it)->beginDocument( m_xml ); FailedTests failedTests; fillFailedTestsMap( failedTests ); @@ -85,9 +86,7 @@ XmlOutputter::makeRootNode() addStatistics( rootNode ); for ( Hooks::const_iterator itEnd = m_hooks.begin(); itEnd != m_hooks.end(); ++itEnd ) - (*itEnd)->endDocument( m_xml, rootNode ); - - return rootNode; + (*itEnd)->endDocument( m_xml ); } @@ -141,16 +140,16 @@ XmlOutputter::addSuccessfulTests( FailedTests &failedTests, void XmlOutputter::addStatistics( XmlElement *rootNode ) { - XmlElement *statisticsNode = new XmlElement( "Statistics" ); - rootNode->addElement( statisticsNode ); - statisticsNode->addElement( new XmlElement( "Tests", m_result->runTests() ) ); - statisticsNode->addElement( new XmlElement( "FailuresTotal", - m_result->testFailuresTotal() ) ); - statisticsNode->addElement( new XmlElement( "Errors", m_result->testErrors() ) ); - statisticsNode->addElement( new XmlElement( "Failures", m_result->testFailures() ) ); + XmlElement *statisticsElement = new XmlElement( "Statistics" ); + rootNode->addElement( statisticsElement ); + statisticsElement->addElement( new XmlElement( "Tests", m_result->runTests() ) ); + statisticsElement->addElement( new XmlElement( "FailuresTotal", + m_result->testFailuresTotal() ) ); + statisticsElement->addElement( new XmlElement( "Errors", m_result->testErrors() ) ); + statisticsElement->addElement( new XmlElement( "Failures", m_result->testFailures() ) ); for ( Hooks::const_iterator it = m_hooks.begin(); it != m_hooks.end(); ++it ) - (*it)->statisticsAdded( m_xml, statisticsNode ); + (*it)->statisticsAdded( m_xml, statisticsElement ); } @@ -162,30 +161,30 @@ XmlOutputter::addFailedTest( Test *test, { Exception *thrownException = failure->thrownException(); - XmlElement *testNode = new XmlElement( "FailedTest" ); - testsNode->addElement( testNode ); - testNode->addAttribute( "id", testNumber ); - testNode->addElement( new XmlElement( "Name", test->getName() ) ); - testNode->addElement( new XmlElement( "FailureType", - failure->isError() ? "Error" : - "Assertion" ) ); + XmlElement *testElement = new XmlElement( "FailedTest" ); + testsNode->addElement( testElement ); + testElement->addAttribute( "id", testNumber ); + testElement->addElement( new XmlElement( "Name", test->getName() ) ); + testElement->addElement( new XmlElement( "FailureType", + failure->isError() ? "Error" : + "Assertion" ) ); if ( failure->sourceLine().isValid() ) - addFailureLocation( failure, testNode ); + addFailureLocation( failure, testElement ); - testNode->addElement( new XmlElement( "Message", thrownException->what() ) ); + testElement->addElement( new XmlElement( "Message", thrownException->what() ) ); for ( Hooks::const_iterator it = m_hooks.begin(); it != m_hooks.end(); ++it ) - (*it)->failTestAdded( m_xml, testNode, test, failure ); + (*it)->failTestAdded( m_xml, testElement, test, failure ); } void XmlOutputter::addFailureLocation( TestFailure *failure, - XmlElement *testNode ) + XmlElement *testElement ) { XmlElement *locationNode = new XmlElement( "Location" ); - testNode->addElement( locationNode ); + testElement->addElement( locationNode ); SourceLine sourceLine = failure->sourceLine(); locationNode->addElement( new XmlElement( "File", sourceLine.fileName() ) ); locationNode->addElement( new XmlElement( "Line", sourceLine.lineNumber() ) ); @@ -197,13 +196,13 @@ XmlOutputter::addSuccessfulTest( Test *test, int testNumber, XmlElement *testsNode ) { - XmlElement *testNode = new XmlElement( "Test" ); - testsNode->addElement( testNode ); - testNode->addAttribute( "id", testNumber ); - testNode->addElement( new XmlElement( "Name", test->getName() ) ); + XmlElement *testElement = new XmlElement( "Test" ); + testsNode->addElement( testElement ); + testElement->addAttribute( "id", testNumber ); + testElement->addElement( new XmlElement( "Name", test->getName() ) ); for ( Hooks::const_iterator it = m_hooks.begin(); it != m_hooks.end(); ++it ) - (*it)->successfulTestAdded( m_xml, testNode, test ); + (*it)->successfulTestAdded( m_xml, testElement, test ); } -- cgit v1.2.1