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 ...
Get Test Driven Development: By Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.