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

  • 相关阅读:
    C#委托 delegate
    认识反射
    【译】修改大XML文件的有效方法
    学习javascript并解读JQuery
    ASP.Net用户验证的实现
    渴望
    C++中常见的一些小问题总结(一)
    struts2:关于EL能够获得action的属性
    排序算法总结
    WebService开发实例
  • 原文地址:https://www.cnblogs.com/dmtz/p/10999618.html
Copyright © 2011-2022 走看看