How to do it...

Let's see how we can characterize the results of a test with this example:

  1. Import the relevant module:
import unittest
  1. Define the outcomesTest class, which has the TestCase subclass as its argument:
class OutcomesTest(unittest.TestCase):
  1. The first method we define is testPass:
    def testPass(self):
return
  1. Here is the TestFail method:
    def testFail(self):
self.failIf(True)
  1. Next, we have the TestError method:
    def testError(self):
raise RuntimeError('test error!')
  1. Finally, we have the main function, with which we recall our procedure:
if __name__ == '__main__':
unittest.main()
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset