test_Userskip.py 1.64 KB
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# import configParser
import unittest

class test_Userskip_demo1(unittest.TestCase):
    
#     @unittest.skip("debgu666")
    def test_1_userskip(self):
        print('in test_1')
        
    @unittest.skipDepend(depend="test_1_userskip")
    def test_2_userskip(self):
#         raise Exception("666")
        assert False
        print('in test_2')
        
    #test_3依赖test_2,当test_2发生错时,不会运行test_3
    @unittest.skipDepend(depend="test_2_userskip")
    def test_3_userskip(self):
#         print()
#         print("failures",self._outcome.result.failures)
#         print("errors",self._outcome.result.errors)
#         print("skipped",self._outcome.result.skipped)
        print('in test_3')

    @unittest.skipDepend(depend="test_1_userskip")
    def test_4_userskip(self):
        print('in test_4')
        
    @unittest.skipDepend(depend="test_2_userskip")
    def test_5_userskip(self):
        assert False
        print('in test_5')

    def test_6(self):
        print('in test_6')
        
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)