当前位置:网站首页>Unittest attempt
Unittest attempt
2022-07-03 06:33:00 【Bobo AI leaves work】
1. Inheritance class
import unittest
class TestApi(unittest.TestCase):
def test_01_login(self):
print(" Test landing ")
def test_02_login(self):
print(" Test registration ")
2. Usage of test suite unittest.main(defaultTest="suite")
import unittest
from test_apis.test_api import TestApi
if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(TestApi("test_01_login"))
# Add a set of test cases
testcases=[TestApi("test_01_login"),TestApi("test_02_login")]
suite.addTests(testcases)
unittest.main(defaultTest="suite")
3. Through the loader TestLoader load
import unittest
from test_apis.test_api import TestApi
if __name__ == '__main__':
suite=unittest.defaultTestLoader.discover("./",pattern="test_*.py")
unittest.main(defaultTest="suite")
Assert whether the titles are equal :
import unittest
from selenium import webdriver
class Test_Bai(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
driver=webdriver.Chrome()
driver.get("http://www.baidu.com")
title=driver.title
print(title)
return title
def test_assert_title(self):
self.assertEqual(self.setUpClass()," use Baidu Search , You will know ")
if __name__ == '__main__':
unittest.main
边栏推荐
- ROS+Pytorch的联合使用示例(语义分割)
- Oracle Database Introduction
- Cesium 点击获取模型表面经纬度高程坐标(三维坐标)
- The most classic 100 sentences in the world famous works
- 剖析虚幻渲染体系(16)- 图形驱动的秘密
- 2022 CISP-PTE(三)命令执行
- 10万奖金被瓜分,快来认识这位上榜者里的“乘风破浪的姐姐”
- SQL实现将多行记录合并成一行
- 【LeetCode】Day93-两个数组的交集 II
- Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface
猜你喜欢
2022 CISP-PTE(三)命令执行
Method of converting GPS coordinates to Baidu map coordinates
Interesting research on mouse pointer interaction
“我为开源打榜狂”第一周榜单公布,160位开发者上榜
YOLOV1学习笔记
[open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle
第8章、MapReduce 生产经验
Svn branch management
Oauth2.0 - using JWT to replace token and JWT content enhancement
scroll-view指定滚动元素的起始位置
随机推荐
【5G NR】UE注册流程
Creating postgre enterprise database by ArcGIS
Kubesphere - set up redis cluster
“我为开源打榜狂”第一周榜单公布,160位开发者上榜
[set theory] equivalence relation (concept of equivalence relation | examples of equivalence relation | equivalence relation and closure)
【系统设计】邻近服务
有意思的鼠標指針交互探究
2022 cisp-pte (III) command execution
ODL framework project construction trial -demo
ruoyi接口权限校验
学习笔记 -- k-d tree 和 ikd-Tree 原理及对比
Kubesphere - build MySQL master-slave replication structure
Oauth2.0 - using JWT to replace token and JWT content enhancement
表达式的动态解析和计算,Flee用起来真香
【无标题】8 简易版通讯录
Merge and migrate data from small data volume, sub database and sub table Mysql to tidb
Condition annotation in uni-app realizes cross segment compatibility, navigation jump and parameter transfer, component creation and use, and life cycle function
23 design models
Kubesphere - Multi tenant management
Local rviz call and display of remote rostopic