当前位置:网站首页>自动化测试——关于unitest与pytest初始化共存问题
自动化测试——关于unitest与pytest初始化共存问题
2022-06-26 09:34:00 【坦桑尼亚奥杜威峡谷能人】
经测试:
setUp、setUpClass、setup_class
在两个框架都可以跑
# -*- coding: utf-8 -*-
# 导包
import json
import requests
import unittest
import pytest
import allure
@allure.feature("自动化测试")
@allure.story('平台:登录测试')
@allure.description('测试case')
@allure.severity('normal') # 标记用例登记
class TestCase(unittest.TestCase):
# # 初始化 pytest、unitest 都可以
# def setUp(self):
# print("测试开始。。。")
#
# # 卸载
# def tearDown(self):
# print("测试结束。。。")
# # 初始化 pytest、unitest 都可以, 但是必须加 @classmethod
# @classmethod
# def setUpClass(cls) -> None:
# print("测试开始。。。")
#
# # 卸载
# @classmethod
# def tearDownClass(cls) -> None:
# print("测试结束。。。")
# 初始化 pytest、unitest 都可以
def setup_class(self):
print("测试开始。。。")
# 卸载
def teardown_class(self):
print("测试结束。。。")
# 测试函数2:登录成功函数
@allure.title("case: 成功")
def test_001(self):
# 直接发送请求
print('测试用例。。。')
# 断言判断
self.assertEqual(200, 200)
# # 测试函数2:登录成功函数
# @allure.title("case: 失败")
# def test_002(self):
# # 直接发送请求
# print('测试用例。。。')
#
# # 断言判断
# self.assertEqual(201, 200)
if __name__ == "__main__":
unittest.main()
# pytest.main()
边栏推荐
- Catalogue gradué de revues scientifiques et technologiques de haute qualité dans le domaine de l'informatique
- The first problem troubleshooting process of re disk
- Classified catalogue of high quality sci-tech periodicals in the field of computing
- Summary of common commands of vim
- Notes on sports planning on November 22, 2021
- install opencv-contrib-dev to use aruco code
- QPM suspended window setting information
- "One week's data collection" -- combinational logic circuit
- LeetCode 0710. Random numbers in the blacklist - preprocessing implementation o (1) value
- Industrial and enterprise patent matching data (hundreds of thousands of data) 1998-2014
猜你喜欢

【AAAI 2021】Few-Shot One-Class Classification via Meta-Learning 【FSOCC via Meta-learning】

【CVPR 2019】Semantic Image Synthesis with Spatially-Adaptive Normalization(SPADE)

How to solve the sample imbalance problem in machine learning?

Badge series 5: use of codecov

Redis notes (14) - persistence and data recovery (data persistence RDB and AOF, data recovery, mixed persistence)

"One week's data collection" -- combinational logic circuit

Regular expression learning

Wechat official account reported error 10003
QPM performance monitoring components - General

Cancellation and unbinding of qiniu cloud account
随机推荐
爬虫相关文章收藏:pyppeteer 、Burpsuite
c语言语法基础之——局部变量及存储类别、全局变量及存储类别、宏定义 学习
How to correctly open the USB debugging and complete log functions of Huawei mobile phones?
逻辑英语结构【重点】
Js--- get the data with the same key value in the object array to get a new array
Redis novice introduction
What you need to know to test -- URL, weak network, interface, automation
install realsense2: The following packages have unmet dependencies: libgtk-3-dev
Optimization of power assisted performance of QPM suspended window
How to view the data mini map quickly and conveniently after importing data in origin
[open5gs] open5gs installation configuration
logback
我的创作纪念日
Learning to Generalize Unseen Domains via Memory-based Multi-Source Meta-Learning for Person Re-ID
LeetCode 剑指 Offer II 091.粉刷房子 - 原地修改
LeetCode 0710.黑名单中的随机数 - 预处理实现O(1)取值
【CVPR 2021】DatasetGAN: Efficient Labeled Data Factory with Minimal Human Effort
【CVPR 2019】Semantic Image Synthesis with Spatially-Adaptive Normalization(SPADE)
SQL modification of table structure
Jz2440 - - - utiliser le programme de gravure uboot