zoukankan      html  css  js  c++  java
  • 套件的使用追加

    方法一: 执行类下面的 测试case

    if __name__ == '__main__':
    suiteTest = unittest.TestSuite()
    suiteTest.addTest(TestAuto("testCase_001"))
    suiteTest.addTest(TestAuto("testCase_002"))
    unittest.TextTestRunner(verbosity=2).run(suiteTest)

    # 按照一定时间格式获取当前时间(防止测试报告覆盖)
    now = time.strftime(u'%Y-%m-%d-%H-%M-%S')
    # 确定生成报告的路径
    report_file = "F:\python3\report\" + now + "_test_report.html"
    with open(report_file, 'wb') as report:
    runner = HTMLTestReportCN.HTMLTestRunner(stream=report, title=u'测试报告',
    description=u'如下为用例执行结果,请查阅!',
    )
    runner.run(suiteTest)
    report.close()

    方法二: 按测试类执行

    if __name__ == '__main__':
    suiteTest = unittest.TestSuite(unittest.makeSuite(TestAuto))
    '''
    这里的verbosity是一个选项,表示测试结果的信息复杂度,有三个值
    0 (静默模式): 你只能获得总的测试用例数和总的结果 比如 总共100个 失败20 成功80
    1 (默认模式): 非常类似静默模式 只是在每个成功的用例前面有个“.” 每个失败的用例前面有个 “F”
    2 (详细模式):测试结果会显示每个测试用例的所有相关的信息
    并且 你在命令行里加入不同的参数可以起到一样的效果
    加入 –quiet 参数 等效于 verbosity=0
    '''
    unittest.TextTestRunner(verbosity=2).run(suiteTest)

    # 按照一定时间格式获取当前时间(防止测试报告覆盖)
    now = time.strftime(u'%Y-%m-%d-%H-%M-%S')
    # 确定生成报告的路径
    report_file = "F:\python3\report\" + now + "_test_report.html"
    with open(report_file, 'wb') as report:
    runner = HTMLTestReportCN.HTMLTestRunner(stream=report, title=u'测试报告',
    description=u'如下为用例执行结果,请查阅!',
    )

    runner.run(suiteTest)
    report.close()

    方法三: 执行一个文件

    f __name__ == '__main__':
    suiteTest = unittest.Testloader().loadTestsFromModule('seleniumtest.py')
    '''
    这里的verbosity是一个选项,表示测试结果的信息复杂度,有三个值
    0 (静默模式): 你只能获得总的测试用例数和总的结果 比如 总共100个 失败20 成功80
    1 (默认模式): 非常类似静默模式 只是在每个成功的用例前面有个“.” 每个失败的用例前面有个 “F”
    2 (详细模式):测试结果会显示每个测试用例的所有相关的信息
    并且 你在命令行里加入不同的参数可以起到一样的效果
    加入 –quiet 参数 等效于 verbosity=0
    '''
    unittest.TextTestRunner(verbosity=2).run(suiteTest)

    # 按照一定时间格式获取当前时间(防止测试报告覆盖)
    now = time.strftime(u'%Y-%m-%d-%H-%M-%S')
    # 确定生成报告的路径
    report_file = "F:\python3\report\" + now + "_test_report.html"
    with open(report_file, 'wb') as report:
    runner = HTMLTestReportCN.HTMLTestRunner(stream=report, title=u'测试报告',
    description=u'如下为用例执行结果,请查阅!',
    )

    runner.run(suiteTest)
    report.close()

    来源: https://mp.weixin.qq.com/s/MiwG6jXCCnTl5Y2FhJTPVg

  • 相关阅读:
    数字签名与HTTPS详解
    利用策略模式优化过多 if else 代码
    Redis 的事务到底是不是原子性的
    Spring Boot项目的接口防刷
    深入分析 ThreadLocal
    什么是四层和七层负载均衡?他们之间的区别是什么?
    MyEclipse或Eclipse中project的导入和导出
    org.hibernate.exception.ConstraintViolationException: could not insert:
    C++ STL vector(向量容器)的使用(附完整程序代码)
    Swift2.0语言教程之函数嵌套调用形式
  • 原文地址:https://www.cnblogs.com/kaibindirver/p/12887133.html
Copyright © 2011-2022 走看看