一份漂亮的Airtest批量执行案例脚本并聚合报告的方法

本文介绍了一种使用Airtest批量执行测试脚本并生成聚合报告的方法。通过在Python3.6环境下创建myRunner.py文件,调用airtest底层方法run_script执行测试,并利用LogToHtml生成HTML报告。这种方法避免了直接修改airtest库文件,提高了代码维护性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一份漂亮的使用Airtest批量执行案例脚本并聚合报告的方法

通过搜集网络上已有的解决方案以及自己研究airtest底层的代码,整理出适合大致的批量执行Airtest脚本的解决方法。

效果图如下:

代码目录结构:img

执行结果图:

img

点击案例名称调整至详细报告:

img

解决方案:

在Python3.6环境下新建myRunner.py文件:编写如下代码

from airtest.cli.runner import AirtestCase, run_script
from argparse import *
import airtest.report.report as report
import jinja2
import shutil
import os
import io


class CustomAirtestCase(AirtestCase):
    def setUp(self):
        print("custom setup")
		# add var/function/class/.. to globals
        # self.scope["hunter"] = "i am hunter"
        # self.scope["add"] = lambda x: x+1
        # exec setup script
        # self.exec_other_script("setup.owl")
        super(CustomAirtestCase, self).setUp()
    def tearDown(self):
        print("custom tearDown")
        # exec teardown script
        # self.exec_other_script("teardown.owl")
        super(CustomAirtestCase, self).setUp()
    def run_air(self, root_dir='D:\\tools\\airtestCase\\案例集', device=['android://127.0.0.1:5037/99.12.74.40:7281']):

        # 聚合结果
        results = []
        # 获取所有用例集
        root_log = root_dir + '\\' + 'log'
        if os.path.isdir(root_log):
            shutil.rmtree(root_log)
        else:
            o
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值