当前位置:网站首页>Unit test framework + Test Suite
Unit test framework + Test Suite
2022-07-03 06:33:00 【Bobo AI leaves work】
Unit test framework
import unittest
class Test_api(unittest.TestCase):
def test_mashang(self):
print('ms3435')
def test_mashang2(self):
print('ms2')
def test_mashang3(self):
print('ms3')
self.assertTrue(True)test suite
import unittest
from test_api import Test_api
if __name__=='__main__':
suite=unittest.TestSuite()
suite.addTest(Test_api('test_mashang'))
unittest.main(defaultTest='suite')Test kit transmitter ( Start the py file ):
import unittest
from test_api import Test_api
if __name__=='__main__':
unittest.defaultTestLoader.discover(r'D:\pycharm\PyCharm Community Edition 2021.1.3\jbr\bin\pythonProject\pythonProject37', pattern='test*.py',)
unittest.main()result
OK
ms3435
ms2
ms3
setUp and tearDown
Ordinary ones don't need decorators , Class methods need decorators @classmethod Otherwise, it will report a mistake
class Test_api(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
print(' front ')
@classmethod
def tearDownClass(cls) -> None :
print(' After after ')Unconditionally ignore decorators :
@unittest.skip(reason=' Unconditionally ignore ')
def test_mashang2(self):
print('ms2')True Conditional ignore decorator :
age=16
@unittest.skipIf(age<18,reason=' Age is less than 18, A minor ')
def test_mashang(self):
print('ms3435')False Conditional ignore decorator :
age=20
@unittest.skipUnless(age<18,reason=' Ignore ')
def test_mashang(self):
print('ms3435')Assertion judgement
On the current website :
Self.assertin(‘index.php’,driver.current_url)
In source On :
Driver.switch_to frame(' Frame name ')
Self.assertin(‘ sign out ’,driver,page_source)
Driver.switch_to.default_content()
Locate a set of elements
Locate a set of elements :
Driver,fing_elements(By.XPATH,’//IMG[@src=’images/icon_edit.gif’)
Print(len(list))
Click on the first element
List[0].click()
F12 You can pause the browser
The text asserts
text=Driver,fing_elements(By.XPATH,’//IMG[@src=’images/icon_edit.gif’).text
Print(text)
Self.assertequan(text,’ Edit product successfully ’
边栏推荐
- 【无标题】
- Yolov2 learning and summary
- Project summary --04
- Cannot get value with @value, null
- Scroll view specifies the starting position of the scrolling element
- Cesium 点击获取模型表面经纬度高程坐标(三维坐标)
- Use selenium to climb the annual box office of Yien
- 爬虫代码基础教学
- [untitled] 8 simplified address book
- 輕松上手Fluentd,結合 Rainbond 插件市場,日志收集更快捷
猜你喜欢

In depth analysis of kubernetes controller runtime

Paper notes vsalm literature review "a comprehensive survey of visual slam algorithms"

【无标题】

10万奖金被瓜分,快来认识这位上榜者里的“乘风破浪的姐姐”

YOLOV3学习笔记

100000 bonus is divided up. Come and meet the "sister who braves the wind and waves" among the winners

Phpstudy setting items can be accessed by other computers on the LAN

Use selenium to climb the annual box office of Yien

23 design models

有意思的鼠標指針交互探究
随机推荐
【无标题】5 自用历程
剖析虚幻渲染体系(16)- 图形驱动的秘密
Mysql5.7 group by error
Shell conditional statement
“我为开源打榜狂”第一周榜单公布,160位开发者上榜
SQL实现将多行记录合并成一行
Zhiniu stock -- 03
error C2017: 非法的转义序列
Oauth2.0 - using JWT to replace token and JWT content enhancement
The difference between CONDA and pip
【系统设计】邻近服务
Cesium entity(entities) 实体删除方法
Decision tree of machine learning
【LeetCode】Day93-两个数组的交集 II
Opencv mouse and keyboard events
The list of "I'm crazy about open source" was released in the first week, with 160 developers on the list
Interesting research on mouse pointer interaction
SSH link remote server and local display of remote graphical interface
技术管理进阶——你了解成长的全貌吗?
ROS+Pytorch的联合使用示例(语义分割)