python unittest setUp tearDown
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName :Use case preconditions.py
# @Time :2020\10\28 0028 22:22
# @Author :Krystal
# @Desc :Testcase
import unittest
class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
# It executes once before all use cases run
print('SetUpClass')
@classmethod
def tearDownClass(cls):
# After all the use cases have been run, it is executed once
print('tearDownClass')
def tearDown(self):
# Each test case is executed after it is run
print('tearDown')
def setUp(self):
# Each test case is executed before it is run
print('setUp')
def testa(self):
print('testa')
def testz(self):
print('testz')
def testb(self):
print('testb')
def testc(self):
print('testc')
if __name__ == "__main__":
unittest.main()