当前位置:网站首页>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
边栏推荐
- C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
- ssh链接远程服务器 及 远程图形化界面的本地显示
- Judge whether the date time exceeds 31 days
- Numerical method for solving optimal control problem (I) -- gradient method
- 有意思的鼠标指针交互探究
- The most classic 100 sentences in the world famous works
- 冒泡排序的简单理解
- After the Chrome browser is updated, lodop printing cannot be called
- SQL实现将多行记录合并成一行
- [leetcode] day93 - intersection of two arrays II
猜你喜欢

Creating postgre enterprise database by ArcGIS

Selenium - by changing the window size, the width, height and length of different models will be different

【无标题】

IE browser flash back, automatically open edge browser

Project summary --04

Read blog type data from mysql, Chinese garbled code - solved

JMeter linked database

Selenium - 改变窗口大小,不同机型呈现的宽高长度会不一样

Scripy learning

Paper notes vsalm literature review "a comprehensive survey of visual slam algorithms"
随机推荐
Docker advanced learning (container data volume, MySQL installation, dockerfile)
JMeter performance automation test
Yolov2 learning and summary
Push box games C #
Printer related problem record
Interface test weather API
【5G NR】UE注册流程
Migrate data from Mysql to tidb from a small amount of data
Cannot get value with @value, null
Derivation of variance iteration formula
Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
简易密码锁
Cesium 点击获取模型表面经纬度高程坐标(三维坐标)
【无标题】5 自用历程
Support vector machine for machine learning
The difference between CONDA and pip
The win7 computer can't start. Turn the CPU fan and stop it
Kubesphere - Multi tenant management
After the Chrome browser is updated, lodop printing cannot be called
PMP notes