From fbd454f554f13680fe62b36fb7a5829f6dc0c396 Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Fri, 5 Oct 2001 21:27:15 +0000 Subject: Include/cppunit/Asserter. include/cppunit/Asserter.h : * src/cppunit/Asserter.cpp : added. Helper to create assertion macros. * src/cppunit/cppunit.dsp : * src/cppunit/Makefile.am : * include/cppunit/Makefile.am : added Asserter.h and Asserter.cpp. * include/cppunit/Exception.h : * src/cppunit/Exception.cpp : added constructor that take a SourceLine argument. Deprecated static constant and old constructor. Fixed some constness issues. * examples/cppunittest/ExceptionTest.cpp : Refactored. * NEWS : partially updated (need to be more detailed) * include/cppunit/NotEqualException.h : * src/cppunit/NotEqualException.cpp : added constructor that take a SourceLine argument. Deprecated old constructor. Added a third element to compose message. * examples/cppunittest/NotEqualExceptionTest.cpp : moved to "Core" suite. Added test for SourceLine() and additionalMessage(). Refactored. * include/cppunit/SourceLine.h : * src/cppunit/SourceLine.cpp : added. Result of applying IntroduceParameterObject refactoring on filename & line number... * include/cppunit/TestAssert.h : * src/cppunit/TestAssert.cpp : deprecated old assert functions. added functions assertEquals() and assertDoubleEquals() which use SourceLine. * src/cppunit/TestCase.cpp : Modified for SourceLine. * include/cppunit/TestFailure.h : * src/cppunit/TestFailure.cpp : added failedTestName(), and sourceLine(). * src/msvc6/testrunner/TestRunnerDlg.cpp : modified to use SourceLine. * include/cppunit/TextTestResult.h : * src/cppunit/TextTestResult.cpp : corrected include order and switched to angled brackets. Refactored. Don't print failure location if not available. Not equal failure dump additional message if available. * src/cppunit/TextTestRunner.cpp : run() now returns a boolean to indicate if the run was sucessful. * src/cppunit/XmlTestResultOutputter.cpp : replaced itoa() with OStringStream. Refactored. * examples/cppunittest/XmlUniformiser.h : * examples/cppunittest/XmlUniformiser.cpp : CPPUNITTEST_ASSERT_XML_EQUAL capture failure location. Refactored checkXmlEqual(). * examples/cppunittest/XmlUniformiserTest.h : * examples/cppunittest/XmlUniformiserTest.cpp : added test for CPPUNITTEST_ASSERT_XML_EQUAL. * include/cppunit/XmlTestResultOutputter.h : * src/cppunit/XmlTestResultOutputter.cpp : updated to use SourceLine. --- src/cppunit/TextTestRunner.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'src/cppunit/TextTestRunner.cpp') diff --git a/src/cppunit/TextTestRunner.cpp b/src/cppunit/TextTestRunner.cpp index aaa6c86..c00c456 100644 --- a/src/cppunit/TextTestRunner.cpp +++ b/src/cppunit/TextTestRunner.cpp @@ -37,34 +37,31 @@ TextTestRunner::addTest( Test *test ) * of an added test. * \param doWait if \c true then the user must press the RETURN key * before the run() method exit. + * \return \c true is the test was successful, \c false if the test + * failed or was not found. */ - -void +bool TextTestRunner::run( std::string testName, bool doWait ) { - runTestByName( testName ); + bool sucessful = runTestByName( testName ); wait( doWait ); + return sucessful; } -void +bool TextTestRunner::runTestByName( std::string testName ) { if ( testName.empty() ) - { - runTest( m_suite ); - } - else - { - Test *test = findTestByName( testName ); - if ( test != NULL ) - runTest( test ); - else - { - std::cout << "Test " << testName << " not found." << std::endl; - } - } + return runTest( m_suite ); + + Test *test = findTestByName( testName ); + if ( test != NULL ) + return runTest( test ); + + std::cout << "Test " << testName << " not found." << std::endl; + return false; } @@ -94,12 +91,13 @@ TextTestRunner::findTestByName( std::string name ) const } -void +bool TextTestRunner::runTest( Test *test ) { TextTestResult result; test->run( &result ); std::cout << result << std::endl; + return result.wasSuccessful(); } -- cgit v1.2.1