当前位置:网站首页>brief introduction
brief introduction
2022-07-28 10:16:00 【Internet Finance chores】
brief introduction
For students who often use automated means to test , Whether using interface automation tools , Or a self-developed testing framework , A complete automation use case , The assertion part is definitely the top priority , Because the granularity of assertions can reflect the quality of use cases to a certain extent , It must be asserted that the finer the particle size , The more likely you are to find problems , For interface testing , Interface return result assertion is required , But that's not enough , It is more recommended that the database data and interface request Assert important fields in , And the essence of assertion is also the comparison between data , For example, equal 、 contain 、 Nonempty .
Introduced today Python library assertP It is such a convenient tool to test students' efficient assertions , Test students directly take the data extracted from the database as the actual results And Compare the expected results . It supports equality assertions 、 Contains assertions 、 Non empty assertion 、JSON Assertion , The specific usage is as follows .
pip install assertPpractice
- Make assertions in combination with the database . First , Create a new test table al_pay, Make some data .
-- Create Table CREATE TABLE `al_pay` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `user_id` varchar(11) COLLATE utf8mb4_bin DEFAULT NULL, `pay_status` varchar(11) COLLATE utf8mb4_bin DEFAULT NULL, `pay_amount` int(11) DEFAULT NULL, `pay_cur` varchar(11) COLLATE utf8mb4_bin DEFAULT NULL, `order_id` varchar(30) COLLATE utf8mb4_bin NOT NULL DEFAULT '', `ext` varchar(200) COLLATE utf8mb4_bin DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;Test code :
import pymysqlfrom assertP import AssertPy_multi, AssertPy# Connect to database , and mysql The format of the server is the same ( Can also be set to gbk, gb2312)conn = pymysql.connect(host="localhost", user="root", passwd="123456", db='article', charset='utf8', port=3306)cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)# perform sql sentence select_sql = "select order_id, user_id, pay_status, pay_amount from al_pay where order_id=%s;"cursor.execute(select_sql, ("2022010818343700000002",))act = cursor.fetchall()[0]exp = {'order_id': '2022010818343700000001', 'user_id': '20210100002', 'pay_status': 'CLOSED'}# Assertion AssertPy('al_pay', act, exp)conn.commit()cursor.close()conn.close()- Include relationship assertions
act = {'pay_amount': "2000", 'pay_cur': 'RMB', 'order_id': '2022010818343700000001', 'ext': '{"user_name": "QA", "currency": "RMB"}'}exp = {'pay_amount': "CONTAINS_CHECK:2000", 'pay_cur': 'RMB', 'order_id': '2022010818343700000001', 'ext': '{"user_name": "QA", "currency": "RMB"}'}AssertPy(tName, act, exp)- JSON Assertion
act = {'ext': '{"user_name": "QA", "currency": "RMB"}'}exp = {'ext': 'JSON:{"user_name": "QA", "currency": "USD"}'}AssertPy(tName, act, exp)- Multiple data assertions
tName = "TestTable" act = [{'order_id': '2022010818343700000003', 'user_id': '20210100002', 'pay_status': 'PAYING'}, {'order_id': '2022010818343700000003', 'user_id': '20210100001', 'pay_status': 'SUCCESS'}] exp = [{'order_id': '2022010818343700000003', 'user_id': '20210100002', 'pay_status': 'PAYING'}, {'order_id': '2022010818343700000003', 'user_id': '20210100001', 'pay_status': 'SUCCESS'}] AssertPy_multi(tName, act, exp)More assertion types , Extension ...
attach
assertP:https://pypi.org/project/assertP/
Selquel pro:www.sequelpro.com/
Python texttable:https://pypi.org/project/texttable/
PyMySQL:https://pypi.org/project/PyMySQL/
logging:https://docs.python.org/3/library/logging.html
边栏推荐
- [esp32][esp idf][lvgl7.9] failed to compile with OLED IIC
- 10分钟快速入门EVS【玩转华为云】
- Thinking and summary of technical personnel | R & D Efficiency
- Digital transformation scheme of real estate: all-round digital intelligence system operation, helping real estate enterprises improve the effectiveness of management and control
- What are the highlights of B2B2C system? How to help jewelry enterprises build an omni channel multi merchant mall management system
- Prometheus 运维工具 Promtool (四)TSDB 功能
- Summary of key points of bank entry examination
- Redis design specification
- Go json.Decoder Considered Harmful
- Xiao Hei stands up again and looks at leetcode:653. Sum of two IV - enter BST
猜你喜欢

What are the advantages of MRO purchasing website for industrial products? One article will help you understand

7、二分法——寻找一组重复或者有序但是旋转的数组

What kind of knowledge payment system functions are more conducive to the development of the platform and lecturers?
![[esp32][esp idf][lvgl7.9] failed to compile with OLED IIC](/img/16/e5aa43df6ef9bdbc173fa547c85559.png)
[esp32][esp idf][lvgl7.9] failed to compile with OLED IIC

B2B2C系统亮点是什么?如何助力珠宝首饰企业打造全渠道多商户商城管理体系

ES (8.1) certification topic

我用小程序容器让移动研发效率提升了5倍!

语音聊天app——如何规范开发流程?

On July 13, 2021, we collapsed like this

Redis面试题必知必会
随机推荐
Netease written test No. 2 -- typical application of European distance
Uni app advanced creation component / native rendering
[jzof] 14 cut rope
Talk about the problem of preventing others from debugging websites through console based on JS implementation
华为入股石墨烯材料厂商富烯科技,持股10%
【云驻共创】企业数字化转型,华为云咨询与你同行
巧用ngx_lua做流量分组
10 minute quick start EVs [play Huawei cloud]
Xiao Hei stands up again and looks at leetcode:653. Sum of two IV - enter BST
B2B e-commerce website scheme for building materials industry: enable the transformation and upgrading of building materials enterprises to achieve cost reduction and efficiency improvement
PHP生成二维码(学习)
2. 输出数组中重复的数字之一
双指针技巧
Kubernetes
Tencent technical experts: decrypt the 100 million user products wechat, QQ, King glory... Comprehensively practice on the cloud!
关于软考高级要不要报班学习
Description of landingsite electronic label quppa firmware entering DFU status
指令系统超全知识点详解
matlab特征点提取--记录自用
2021-10-13arx