Behave使用体验

behave+uiautomator2+jenkins

同理,Behave也可以和Appium/AirTest框架结合

运行环境

bash 复制代码
pip install uiautomator2 behave behave2cucumber

意事项:behave版本号建议=1.2.5,因为1.2.6和Jenkins Cucumber Report插件不兼容

生成报告

html报告

bash 复制代码
behave -f behave_html_formatter:HTMLFormatter -o report.html

allure报告

bash 复制代码
behave -f allure_behave.formatter:AllureFormatter -o allure-results
allure generate allure-results -o allure_html

Jenkins配置

安装插件:Cucumber reports&Post build task

配置步骤

定时任务

bash 复制代码
H 20 * * *
bash 复制代码
cd /Users/wan/PycharmProjects/Downloader
venv/bin/behave --lang=zh-CN -f json.pretty -o './test_report.json'
bash 复制代码
/Users/wan/PycharmProjects/Downloader/report
bash 复制代码
#!/bin/bash
FEISHU_WEBHOOK_URL="your url"
JOB_NAME="$JOB_NAME"
BUILD_NUMBER="$BUILD_NUMBER"
BUILD_URL="$BUILD_URL"
EXIT_STATUS="$?"
BUILD_RESULT=""
if [ $EXIT_STATUS -eq 0 ]; then
    BUILD_RESULT="成功"
else
    BUILD_RESULT="失败"
fi
BUILD_TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
PAYLOAD="{
    \"msg_type\": \"interactive\",
    \"card\": {
        \"config\": {
            \"wide_screen_mode\": true
        },
        \"header\": {
            \"title\": {
                \"content\": \"Downloader网站回归测试结果\",
                \"tag\": \"plain_text\"
            }
        },
        \"elements\": [
            {
                \"tag\": \"div\",
                \"text\": {
                    \"content\": \"**项目:** $JOB_NAME\\n**构建号:**$BUILD_NUMBER\\n**构建结果:** $BUILD_RESULT\\n**构建时间:**$BUILD_TIMESTAMP\",
                    \"tag\": \"lark_md\"
                }
            },
            {
                \"tag\": \"action\",
                \"actions\": [
                    {
                        \"tag\": \"button\",
                        \"text\": {
                            \"content\": \"查看详情\",
                            \"tag\": \"plain_text\"
                        },
                        \"type\": \"primary\",
                        \"url\": \"$BUILD_URL\"
                    }
                ]
            }
        ]
    }
}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" "$FEISHU_WEBHOOK_URL"
相关推荐
LAKERS_20244 个月前
App自动化测试_Python+Appium使用手册
python·appium·app自动化测试
葉飞纷飞8 个月前
Pycharm Community 配置调试Behave
ide·python·pycharm·behave
wumingxiaoyao9 个月前
BDD - Python Behave Retry 机制
python·retry·bdd·behave
oscar99910 个月前
Python BDD 框架比较之 pytest-bdd vs behave
python·pytest·behave·pytest-bdd
网易测试开发猿10 个月前
【自动化测试】Appium环境搭建与配置-详细步骤,一篇带你打通...
自动化测试·软件测试·软件测试工程师·appium·app测试·自动化测试框架·app自动化测试
软件测试凡哥1 年前
测试中Android与IOS分别关注的点
自动化测试·软件测试·软件测试工程师·程序人生·appium·app自动化测试
阿里测试君1 年前
APP自动化测试-Python+Appium+Pytest+Allure框架实战封装(详细)
自动化测试·软件测试·python自动化测试·appium·pytest·自动化测试框架·app自动化测试