unittest編寫規(guī)范:
- 測試模塊首先import unittest
- 測試類必須繼承unittest.TestCase
- 測試方法必須以"test_開頭"
unittest提供了相關(guān)的組件
- test cases
- test suites
- test fixtrue
- test runner

image.png
斷言:

image.png
執(zhí)行測試用例:

image.png
執(zhí)行測試用例:

image.png

image.png

image.png
例子:

image.png

image.png
HTMLtestrunner: