O'Reilly logo

Test Driven Development: By Example by Kent Beck

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 22. Dealing with Failure

Invoke test methodInvoke setUp firstInvoke tearDown afterwardInvoke tearDown even if the test method failsRun multiple testsReport collected resultsLog string in WasRunReport failed tests

We'll write a smaller grained test to ensure that if we note a failed test, we print out the right results:

TestCaseTest
 def testFailedResultFormatting(self):
					result= TestResult()
					result.testStarted()
					result.testFailed()
					assert("1 run, 1 failed" == result.summary())
				

“testStarted()” and “testFailed()” are the messages we expect to send to the result when a test starts and when a test fails, respectively. If we can get the summary to print correctly when these messages are sent in this order, then our programming ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required