首页 > Web开发 > 详细

安装HTMLTestRunner库

时间:2020-05-19 16:13:20      阅读:41      评论:0      收藏:0      [点我收藏+]

安装 HTMLTestRunner 库的方法非常简单,直接 pip 就可以了

pip install html-testRunner

 

在 https://pypi.org/  中可以直接搜索到,并且官方还提供了详细的文档,操作起来非常的简单

 

官方示例代码:

import HtmlTestRunner
import unittest


class TestStringMethods(unittest.TestCase):

    def test_upper(self):
        self.assertEqual(foo.upper(), FOO)

    def test_error(self):
        """ This test should be marked as error one. """
        raise ValueError

    def test_fail(self):
        """ This test should fail. """
        self.assertEqual(1, 2)

    @unittest.skip("This is a skipped test.")
    def test_skip(self):
        """ This test should be skipped. """
        pass

if __name__ == __main__:
    unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output=example_dir))

 

这是运行后,生成的 HTML 网页

 

技术分享图片

 

安装HTMLTestRunner库

原文:https://www.cnblogs.com/shiyixirui/p/12917452.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!