当前位置:网站首页>Unittest+airtest+beatiulreport combine the three to make a beautiful test report
Unittest+airtest+beatiulreport combine the three to make a beautiful test report
2022-07-04 10:37:00 【Pot pot pot】
Netease open source airtest library , Itself is a python Third party Library , And his airtestIDE Is a powerful integration tool .
From another perspective of the author , With airtest Out of the perfect use of documents , It's more meaningful for white people like us .
Here is the effect
Refer to the author's link :
https://www.jianshu.com/p/e62d3640c07c
First introduce the three :
1、airtest It's a recent popular game UI The test framework , Click through image recognition , Assert whether the image exists, etc. to achieve the purpose of Automation . compatible Ios,Android platform .
2、unittest It is python The unit test framework of , Be similar to java Of junit.
3、beautifulreport It is specially designed for unitest Engaged in html The test reports .
preparation :
1、 clone beautifulreport project ,github Here it is written in great detail
https://github.com/TesterlifeRaymond/BeautifulReport
2、 Get ready python Environmental Science , And import airtest library , Installation depends on the official
https://github.com/AirtestProject/Airtest
4、 Post the use cases I wrote .(PS, Before running this use case , Be sure to connect your phone and turn on developer mode ,adb The connection is normal . It can be used adb devices Check )
# -*- encoding=utf8 -*-
__author__ = "guozehui"
from airtest.core.api import *
import unittest
from BeautifulReport import BeautifulReport
import os
auto_setup(__file__)
class WTestcase(unittest.TestCase):
img_path = 'img'
def save_img(self, img_name):
"""
Pass in a img_name, And store it in the default file path
:param img_name:
:return:
"""
snapshot(('{}/{}.png'.format(os.path.abspath(self.img_path), img_name)))
@classmethod
def setUpClass(cls):
# Parameter you are after you connect your mobile phone , adopt adb devices The string of things you can see
init_device("Android", "CLB7N18814003069")
def setUp(self):
# Install the computer apk Pack it on your cell phone
install("F:/game/ Your bag .apk")
start_app("com. Your game package name ")
sleep(2.0)
@BeautifulReport.add_test_img(' Health announcements exist ')
def test_demo(self):
""" Start the test """
touch(Template(r"tpl1561020321733.png", record_pos=(-0.17, 0.109), resolution=(2244, 1080)))
assert_exists(Template(r"tpl1561020429302.png", record_pos=(0.003, -0.012), resolution=(2244, 1080)), " Health announcements exist ")
self.save_img(' Health announcements exist ')
def tearDown(self):
home()
@classmethod
def tearDownClass(cls):
stop_app("com. Your game package name ")
uninstall("com. Your game package name ")
if __name__ == '__main__':
unittest.main()
5、 Finally, the report is generated , Run in the following folder “python sample.py”
Follow the steps 1, You should put beautifulreport The project was copied to your run python Environmental ,site-packages The directory . Open this directory , Edit it again sample.py file
"""
@Version: 1.0
@Project: BeautyReport
@Author: Raymond
@Data: 2017/11/17 Afternoon 3:48
@File: sample.py
@License: MIT
"""
import unittest
from BeautifulReport import BeautifulReport
if __name__ == '__main__':
# I almost forgot to say , Of use cases py Documents must be used test start , Or you can change the matching value below
test_suite = unittest.defaultTestLoader.discover('F:/code/ The folder where you store the code ', pattern='test*.py')
result = BeautifulReport(test_suite)
result.report(filename=' Test report ', description=' Start the test ', log_path='.')
Um. , That's it .---------------------------------------------------------------------------------------------------------------------------------------
Long winded
python Its advantage is that it has rich third-party libraries , The premise is that you have to find , So you can pay more attention github Submission of the great gods .
Like the author, I just want to make a demo Take a look at the effect of the test report , Automated testing is a project , If you want to continue , All use cases need to be standardized , So you need to think about how to design the directory structure of this project .
The reference author mentioned earlier , Write your own directory structure , You can think about what you need to do .
https://www.jianshu.com/p/e62d3640c07c
边栏推荐
- [Galaxy Kirin V10] [desktop] can't be started or the screen is black
- Batch distribution of SSH keys and batch execution of ansible
- 183 sets of free resume templates to help everyone find a good job
- Learning XML DOM -- a typical model for parsing XML documents
- Hidden C2 tunnel -- use of icmpsh of ICMP
- Map container
- Online troubleshooting
- [Galaxy Kirin V10] [server] iSCSI deployment
- Read a piece of text into the vector object, and each word is stored as an element in the vector. Convert each word in the vector object to uppercase letters. Output the converted elements in the vect
- Article publishing experiment
猜你喜欢
Rhsca day 11 operation
Software sharing: the best PDF document conversion tool and PDF Suite Enterprise version sharing | with sharing
Development guidance document of CMDB
[machine] [server] Taishan 200
uniapp 小于1000 按原数字显示 超过1000 数字换算成10w+ 1.3k+ 显示
Latex error: missing delimiter (. Inserted) {\xi \left( {p,{p_q}} \right)} \right|}}
Idea SSH channel configuration
Remove linked list elements
Use the data to tell you where is the most difficult province for the college entrance examination!
C language - stack
随机推荐
Quick sort (C language)
[Galaxy Kirin V10] [server] system partition expansion
Network connection (II) three handshakes, four waves, socket essence, packaging of network packets, TCP header, IP header, ACK confirmation, sliding window, results of network packets, working mode of
Differences among opencv versions
[Galaxy Kirin V10] [server] KVM create Bridge
[Galaxy Kirin V10] [desktop and server] FRP intranet penetration
[Galaxy Kirin V10] [desktop] printer
[Galaxy Kirin V10] [server] failed to start the network
Huge number (C language)
DDL language of MySQL database: create, modify alter, delete drop of databases and tables
Introduction to extensible system architecture
[Galaxy Kirin V10] [server] soft RAID configuration
Basic data types of MySQL
PHP代码审计3—系统重装漏洞
Vs201 solution to failure to open source file HPP (or link library file)
Const's constant member function after the function; Form, characteristics and use of inline function
leetcode1229. Schedule the meeting
System. Currenttimemillis() and system Nanotime (), which is faster? Don't use it wrong!
uniapp 小于1000 按原数字显示 超过1000 数字换算成10w+ 1.3k+ 显示
Write a program to judge whether the elements contained in a vector < int> container are 9.20: exactly the same as those in a list < int> container.