当前位置:网站首页>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 边栏推荐
猜你喜欢
随机推荐
Principle of struct2
多线程——Callable接口,lambda
UE4 快速找到打包失败的原因
Bug分类和定级
复现 ASVspoof 2021 baseline RawNet2
PyTorch 对 Batch 中每个样本计算损失 Loss for each sample
Trojaning Attack on Neural Networks 论文阅读笔记
SQL topic sorting
Simple addition calculator
复现 SSL_Anti-spoofing, 使用 wav2vec 2.0 和数据增强的自动说话人认证的欺骗攻击与深度伪造检测
Copy the old project into a web project
Usage of string slicing
UE4 窗口控制(最大化 最小化)
配置FTP虚拟用户及访问控制
21. Merge Two Sorted Lists
UE4 LoadingScreen动态加载启动动画
几个常用的网络诊断命令
TCP transmission
VSCode Latex Workshop 设置 XeLatex 编译
for循环:水仙花案例









