4 單元測試,結對
阿新 • • 發佈:2018-10-08
開始 程序 eat .net inf self. clas 分享圖片 技術
此作業要求參見https://edu.cnblogs.com/campus/nenu/2018fall/homework/2146
git,https://git.coding.net/zhaomeizeng/wc.git
一、測試random是否正常
用例
import unittest from f4_1 import createOperator class testCreateOperator(unittest.TestCase): def test_CreateOperator(self): print("單元測試開始:") operator = ["+", "-", "*", "/"] self.assertIn(createOperator(self),operator) if __name__ == ‘__main__‘: unittest.main()
二、測試生成式子
import unittest from f4_1 import main class testmain(unittest.TestCase): def test_main(self): print("單元測試開始:") self.assertIn(main(),20) if __name__ == ‘__main__‘: unittest.main()
通過測試,發現了很多的程序的小Bug和很多沒有註意到的地方。
4 單元測試,結對