一套框架测试全端,可还行?

自动化测试 · 2020-05-22

背景

众所周知,市面上有很多自动化测试工具,web自动化有selenium,robotframework,playwright等,接口自动化测试工具有httprunner,postman,jmeter等,性能测试有jmeter,loadrunner,locust,nGrinder等,移动端测试有appium,airtest等等。那有没有同时支持多端的工具呢?肯定是有的,airtest支持移动端和web测试,但不支持接口测试(当然可以自行编写脚本实现)。robotframework支持web端、移动端和接口测试,但不支持性能压测。另外,同类的测试工具,各个工具都有自身的特点,比如airtest支持图像识别控件,robotframework可以看成是selenium和appium的高级别封装,降低了代码编写成本,httprunner让接口测试用例通过配置化完成,降低了编写脚本的门槛,也可直接将接口用例转化为性能测试用例,利用locust实现性能测试。那有没有可能将这些工具都整合起来,放在一个框架里实现呢?基于此种构想,airobots诞生了。

简介

airobots的名字,是由airtest+robotframework结合而来,自然,框架也是airtest和robotframework的整合,也可以理解是airtest的web测试插件airtest-selenium的功能扩展。为了还支持接口测试和性能测试,httprunner是个不错的选择,所以也将此工具整合了进来。那么airobots便有了以下能力:

  1. 支持移动端测试
  2. 支持web端测试
  3. 支持桌面应用测试
  4. 支持接口测试
  5. 支持性能测试
  6. 控件识别支持通过xpath(及其他传统艺能)和图像识别
  7. 用例执行基于pytest,可自定义用例执行顺序及实现数据驱动生成用例等
  8. 基于allure的测试报告,高端大气

安装

1. 安装python运行环境

安装过程略,建议安装python3.8及以上版本

2. 安装airobots

Github地址:https://github.com/BSTester/Airobots

一键安装:

pip install airobots -i https://mirrors.aliyun.com/pypi/simple

windows系统下, 如果安装失败, 可能是需要安装C++编译工具: visualcppbuildtools_full.exe, 具体错误请留意控制台报错信息。

运行WEB测试,需要安装ChromeDriver和GeckoDriver,可到https://npm.taobao.org/mirrors/下载安装,或安装nodejs之后执行以下命令安装:

npm install -g chromedriver geckodriver

3. 安装allure

运行allure需要java运行环境,安装java过程略,请自行下载安装并配置好环境变量。

  • Linux

    sudo apt-add-repository ppa:qameta/allure
    sudo apt-get update 
    sudo apt-get install allure
  • Mac OS X

    对于Mas OS,可通过Homebrew进行自动安装

    brew install allure
  • Windows

    对于Windows,可从Scoop命令行安装程序获得Allure。

    要安装Allure,请下载并安装Scoop(下载可能需要翻墙),然后在Powershell中执行

    scoop install allure

执行测试

  • 功能及接口测试

    Allure 报告(推荐)

    airobots -t api ./API/Case/Path/ --alluredir=Results --clean-alluredir              # API测试
    airobots -t web ./Web/Case/Path/ --alluredir=Results --clean-alluredir              # Web测试
    airobots -t android ./Android/Case/Path/ --alluredir=Results --clean-alluredir      # Android测试
    airobots -t ios ./IOS/Case/Path/ --alluredir=Results --clean-alluredir              # IOS测试

    HTML 报告

    airobots -t api ./API/Case/Path/ --html=Results/report.html          # API测试
    airobots -t web ./Web/Case/Path/ --html=Results/report.html          # Web测试
    airobots -t android ./Android/Case/Path/ --html=Results/report.html  # Android测试
    airobots -t ios ./IOS/Case/Path/ --html=Results/report.html          # IOS测试
  • 性能测试

    locusts ./API/Case/Path/                                                            # 性能测试

查看Allure报告

allure serve ./Results

20210308001321

演示项目

Github地址:https://github.com/BSTester/AirobotsDemo

下期介绍怎么用airobots编写web测试用例

测试开发 自动化
Theme Jasmine by Kent Liao