码迷,mamicode.com
首页 > Web开发 > 详细

Unittest+HTMLTestRunner

时间:2018-08-30 01:54:08      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:sse   @class   rdo   tca   pytho   flag   coding   test   \n   

# coding=utf-8
import unittest
import HTMLTestRunner

class CaseTest(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        print("this is class method\n")

    def setUp(self):
        print("this is setup")

    def test01(self):
        # flag = False
        print("this is test01")
        self.assertEqual(‘1‘, ‘2‘, ‘数据错误‘)
        # self.assertNotEqual(1, 2)
        # self.assertTrue(flag)

    # @unittest.skip("CaseTest")  # 用这个方法跳过下面的测试案例

    def test02(self):
        print("this is test02")

    def tearDown(self):
        print("this is teardown")

    @classmethod
    def tearDownClass(cls):
        print("this is tearDownClass")

if __name__ == ‘__main__‘:

    # unittest.main()
    suite = unittest.TestSuite()
    suite.addTest(CaseTest("test02"))
    suite.addTest(CaseTest("test01"))
    # unittest.TextTestRunner().run(suite)
    html_file = r"D:/AppTest/report/report.html"
    fp = open(html_file, "wb")
    HTMLTestRunner.HTMLTestRunner(stream=fp).run(suite)

  

Unittest+HTMLTestRunner

标签:sse   @class   rdo   tca   pytho   flag   coding   test   \n   

原文地址:https://www.cnblogs.com/dudubao/p/9557609.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!