zoukankan      html  css  js  c++  java
  • unittest单元测试框架之测试结果输出到外部文件(四)

    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)
  • 相关阅读:
    2020.12.15
    2020.12.14
    2020.12.13
    2020.12.11
    2020.12.10
    语音合成标记语言(SSML)
    Skyline查询
    win10 VMware 安装 Linux 虚拟机
    图像梯度计算
    Harris Corner Detection
  • 原文地址:https://www.cnblogs.com/yangyang521/p/10073255.html
Copyright © 2011-2022 走看看