Let's see how we can characterize the results of a test with this example:
- Import the relevant module:
import unittest
- Define the outcomesTest class, which has the TestCase subclass as its argument:
class OutcomesTest(unittest.TestCase):
- The first method we define is testPass:
def testPass(self):
return
- Here is the TestFail method:
def testFail(self):
self.failIf(True)
- Next, we have the TestError method:
def testError(self):
raise RuntimeError('test error!')
- Finally, we have the main function, with which we recall our procedure:
if __name__ == '__main__':
unittest.main()