当前位置:网站首页>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
边栏推荐
- Scroll view specifies the starting position of the scrolling element
- Judge whether the date time exceeds 31 days
- 23 design models
- Push box games C #
- Exportation et importation de tables de bibliothèque avec binaires MySQL
- [LeetCode]404. 左叶子之和
- 2022 CISP-PTE(三)命令执行
- Yolov3 learning notes
- 表达式的动态解析和计算,Flee用起来真香
- [system design] proximity service
猜你喜欢

Use abp Zero builds a third-party login module (I): Principles

scroll-view指定滚动元素的起始位置

轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷

SSH link remote server and local display of remote graphical interface

Project summary --04

Migrate data from Mysql to tidb from a small amount of data

ROS+Pytorch的联合使用示例(语义分割)

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

远端rostopic的本地rviz调用及显示

Kubesphere - set up redis cluster
随机推荐
YOLOV3学习笔记
Nacos service installation
Page text acquisition
[untitled] 5 self use history
Support vector machine for machine learning
Some thoughts on machine learning
Decision tree of machine learning
Naive Bayes in machine learning
Une exploration intéressante de l'interaction souris - pointeur
代码管理工具
UNI-APP中条件注释 实现跨段兼容、导航跳转 和 传参、组件创建使用和生命周期函数
A letter to graduating college students
Mysql
Print time Hahahahahaha
冒泡排序的简单理解
Openresty best practices
方差迭代公式推导
JMeter linked database
Chapter 8. MapReduce production experience
Pytorch exercise items