python的自动化测试报告

#coding=utf-8
import HTMLTestRunner
import BeautifulReport
import unittest
class MyTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
print("所有之前运行")
@classmethod
def tearDownClass(cls):
print("所有之后运行")
def setUp(self):
print("之前运行")
def tearDown(self):
print("之后运行")
def test_calc1(self):
'''这是测试报告1'''
print("这是case1")
def test_calc2(self):
'''这是测试报告2'''
print("这是case2")
-------------------------------------------------------------------------------------------------------------------------------------------

# unittest.main()
# test_suite=unittest.TestSuite()
# test_suite.addTest(MyTest('test_calc2'))
# test_suite.addTest(unittest.makeSuite(MyTest))
# f=open('report.html','wb',)
# runner=HTMLTestRunner.HTMLTestRunner(stream=f,title='测试报告',description='涛涛测试报告')
# runner.run(test_suite)
# f.close()
HTMLTestRunner下载地址:
https://pan.baidu.com/s/1mPbGvplcw2o0qpxloyDe0g 密码:ubo4    解压后要放到lib目录下  运行一定要 run ..形式运行

------------------------------------------------------------------------------------------------------------------------------

report=BeautifulReport.BeautifulReport(test_suite)
report.report(description='牛牛报告',filename='report3.html2')
print(report.failure_count)#失败的次数
print(report.success_count)#成功的次数
BeautifulReport下载地址:链接:https://pan.baidu.com/s/1mPbGvplcw2o0qpxloyDe0g 密码:ubo4    解压后要放到site-packages目录下
--------------------------------------------------------------------------------------------------------------------------------------------------
多个用例如何在一个文件运行呢 在selenium新建一个文件夹 case  下面新建两个case  在selenium新建一个执行文件
import  unittest
import BeautifulReport as br
test_suite=unittest.TestSuite()
all_case=unittest.defaultTestLoader.discover('case','*.py')
[test_suite.addTests(case)for case in all_case]
report=br.BeautifulReport(test_suite)
report.report(description='涛涛测试用例',filename='new.html')
---------------------------------------------------------------------------------------------------------------------------------------

 










posted @ 2018-09-15 09:40  taotao12  阅读(2082)  评论(0编辑  收藏  举报