当前位置:网站首页>4、 Testfixture test fixture, or test firmware
4、 Testfixture test fixture, or test firmware
2022-07-25 10:21:00 【Christmas gift box】
Use case files ecshop_login.py:
import os
import unittest
from my_unit import MyUnit
class EcshopLogin(MyUnit):
# The test case
def test01_xiaoming(self):
print(" Test Xiao Ming ")
# The test case
def test02_weiwei(self):
print(" Test Pico ")
# The test case
def test10_xiaohongi(self):
print(" Test Xiaohong ")
class Test2(unittest.TestCase):
def test_login(self):
print(" Test login ")Fixture package file my_unit.py:
import unittest
class MyUnit(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
print("setUpClass: Execute once before each class . Such as : Create database , Generate log object ")
def setUp(self):
print("\nsetUp: Preparation before test cases , Such as : Open the browser , Load web page ")
def tearDown(self):
print("tearDown: Unfinished work after test cases , Such as : Close the browser ")
@classmethod
def tearDownClass(cls) -> None:
print("tearDownClass: Execute once after each class . Such as : Close database connection , Destroy log object ")
Run the file all.py:
import os
import unittest
if __name__ =='__main__':
suite = unittest.TestSuite()
testcase = unittest.defaultTestLoader.discover(start_dir=os.getcwd(),pattern='*.py')
suite.addTests(testcase)
unittest.main(defaultTest='suite')
#unittest.TextTestRunner().run(suite) There is no difference between the results of the two calling methods 边栏推荐
猜你喜欢
随机推荐
shortest-unsorted-continuous-subarray
The ultimate summary of jsonobject parsing JSON format
Pytorch 通过 Tensor 某一维的值将 Tensor 分开的方法(简易)
Angr(二)——angr_ctf
Pytorch 张量列表转换为张量 List of Tensor to Tensor 使用 torch.stack()
Multithreading -- callable interface, lambda
SQL 题目整理
Mouse monitor, Paintbrush
Duplicate SSL_ Anti spoofing, spoofing attacks and deep forgery detection using wav2vec 2.0 and data enhanced automatic speaker authentication
数论--负进制转换
21. Merge Two Sorted Lists
Small knowledge of common classes
Angr(三)——angr_ctf
Nodejs initial experience
几个常用的网络诊断命令
Number theory --- the greatest common divisor and the least common multiple
JSONObject解析json格式的终极总结
Mysql离线部署
Selenium waits for the occurrence of elements and the conditions under which the waiting operation can be performed
Simple addition calculator








