1.test_suit执行测试用例及输出结果前 添加如下代码(打开会新建d:/result.txt文件):

  with open("d:\\result.txt","a") as f:
import unittest
from UnittestDemo.test_mathfunc import TestMathFunc
if __name__ == "__main__":
   suite = unittest.TestSuite()
   # 执行加法、减法、除法
   tests =[TestMathFunc("test_add"),TestMathFunc("test_divide"),TestMathFunc("test_minus")]
   suite.addTests(tests)
   
   with open("d:\\result.txt","a") as f:
     #verbosity = 2 查看完成的执行情况
     runner = unittest.TextTestRunner(stream=f, verbosity=2)
     runner.run(suite)

 

相关文章:

  • 2021-12-12
  • 2021-12-24
  • 2022-03-10
  • 2021-09-01
  • 2022-12-23
猜你喜欢
  • 2022-02-16
  • 2022-03-10
  • 2022-12-23
  • 2021-11-20
相关资源
相似解决方案