20180925-4 單元測試
阿新 • • 發佈:2018-10-09
tps 效果 ase src 技術 testcase 試題 rom 測試
作業要求參見https://edu.cnblogs.com/campus/nenu/2018fall/homework/2146
1、測試隨機生成
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()
20180925-4 單元測試