test_Systemskip.py
1.44 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
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# import configParser
import unittest
class test_systemskip_demo1(unittest.TestCase):
def test_1_systemskip(self):
print('in test_1')
@unittest.skip("skip directly")
def test_2_systemskip(self):
print('in test_2')
@unittest.skipIf(True, 'TEST skipIf True')
def test_3_systemskip(self):
print('in test_3')
@unittest.skipIf(False, 'TEST skipIf False')
def test_4_systemskip(self):
print('in test_4')
@unittest.skipUnless(True, 'TEST skipUnless True')
def test_5_systemskip(self):
print('in test_5')
@unittest.skipUnless(False, 'TEST skipUnless True')
def test_6_systemskip(self):
print('in test_6')
@unittest.expectedFailure
def test_7_systemskip(self):
assert False
if __name__ == "__main__":
#unittest.main()方法会搜索该模块文件下所有以test开头的测试用例方法,并自动执行它们。
#如果不加下面这个语句,那么在通过unittest的方法添加测试用例时,这个文件里面的用例不会被搜索到。
unittest.main(verbosity=2)
# #以下代码可以调试单个测试用例
# current_suite = unittest.TestSuite()
# current_suite.addTest(test_statCard("testcase01"))
# # 执行测试
# runner = unittest.TextTestRunner()
# runner.run(current_suite)