zoukankan      html  css  js  c++  java
  • python unittest--HTMLTestRunner生成报告

    同一个目录下

    test1.py

    import unittest

    class test1(unittest.TestCase):
        u"类1的测试用例"
        def test1(self):
            u"测试用例1"
            print "test001lalala"

        def test2(self):
            u"测试用例2"
            print "test002hahaha"

    test2.py

    import unittest

    class test2(unittest.TestCase):
        u"类2的测试用例"
        def test3(self):
            u"测试用例3"
            print "test001lalala"

        def test4(self):
            u"测试用例4"
            print "test002hahaha"

    run.py

    import unittest
    from HTMLTestRunner import *
    import sys

    reload(sys)
    sys.setdefaultencoding("utf-8")

    def main():
        discover=unittest.TestLoader().discover(".", "test*.py")

        with open('test_result.html', 'wb') as file:
            runner = HTMLTestRunner(stream=file,
                                                       title='测试报告',
                                                      description='xxx测试报告',
                                                      verbosity=2)
            runner.run(discover)


    if __name__=="__main__":
    main()

  • 相关阅读:
    语法树,短语,直接短语,句柄2.0
    语法树,短语,直接短语,句柄
    2.理解文法和语文
    编译原理的学习 No.1
    第一次个人编程作业
    Arduboy基本操作(二)
    Arduboy基本用法(一)
    物理存储管理实训题
    创建和管理用户作业
    PL/SQL语言基础
  • 原文地址:https://www.cnblogs.com/dmtz/p/10999618.html
Copyright © 2011-2022 走看看