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()

  • 相关阅读:
    多项式的一些操作
    AtCoder Grand Contest 036E
    THUWC2017 随机二分图
    THUWC2017 在美妙的数学王国中畅游
    SDOI2017 切树游戏
    ZJOI2017 树状数组
    HNOI2015 接水果
    LOJ6503 Magic
    Charles 抓去app接口的使用
    mysql 字符串类型和数字对比的坑
  • 原文地址:https://www.cnblogs.com/dmtz/p/10999618.html
Copyright © 2011-2022 走看看