Repository navigation
Expand file tree
/
Copy pathtest_HTMLTestRunnerEN.py
More file actions
96 lines (74 loc) · 2.33 KB
/
Copy pathtest_HTMLTestRunnerEN.py
File metadata and controls
96 lines (74 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# -*- coding:utf-8 -*-
import unittest
import HTMLTestRunnerEN
#测试用例
class MyTestCase(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def testCase1(self):
self.assertEqual(2,2,"testCase_Pass")
def testCase2(self):
self.assertEqual(2,3,"testCase_Fail")
def testCase3(self):
self.assertEqual(2,5,"测试错误")
test_error
def testCase4(self):
self.assertEqual(2,2,"测试错误")
findyou
def testCase5(self):
pass
class APITestCase(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def testCase1(self):
self.assertEqual(2, 2, "testCase_Pass")
print("测试打印日志~")
def testCase2(self):
self.assertEqual(3, 3, "testCase_Pass")
print("测试打印日志~")
def testCase3(self):
self.assertEqual(5, 5, "testCase_Pass")
def testCase4(self):
self.assertEqual(2, 1, "testCase_Error")
findyou
def testCase5(self):
self.assertEqual(2, 6, "testCase_Fail")
def testCase6(self):
pass
#添加Suite
def Suite():
#定义一个单元测试容器
suiteTest = unittest.TestSuite()
#将测试用例加入到容器
suiteTest.addTest(MyTestCase("testCase1"))
suiteTest.addTest(MyTestCase("testCase2"))
suiteTest.addTest(MyTestCase("testCase3"))
suiteTest.addTest(MyTestCase("testCase4"))
suiteTest.addTest(MyTestCase("testCase5"))
suiteTest.addTest(APITestCase("testCase1"))
suiteTest.addTest(APITestCase("testCase2"))
suiteTest.addTest(APITestCase("testCase3"))
suiteTest.addTest(APITestCase("testCase4"))
suiteTest.addTest(APITestCase("testCase5"))
suiteTest.addTest(APITestCase("testCase6"))
return suiteTest
if __name__ == '__main__':
#确定生成报告的路径
filePath = '/Users/albert/PycharmProjects/HTMLTestRunnerCN/ReportCN.html'
# filePath = 'F:\\ReportEN.html'
fp = open(filePath,'wb')
#生成报告的Title,描述
runner = HTMLTestRunnerEN.HTMLTestReportEN(
stream=fp,
title='{ Test Report }',
#description='详细测试用例结果',
tester='Findyou'
)
#运行测试用例
runner.run(Suite())
# 关闭文件,否则会无法生成文件
#fp.close()