Behave使用体验

behave+uiautomator2+jenkins

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

运行环境

pip install uiautomator2 behave behave2cucumber

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

生成报告

html报告

behave -f behave_html_formatter:HTMLFormatter -o report.html

allure报告

behave -f allure_behave.formatter:AllureFormatter -o allure-results
allure generate allure-results -o allure_html

Jenkins配置

安装插件:Cucumber reports&Post build task

配置步骤

定时任务

H 20 * * *

cd /Users/wan/PycharmProjects/Downloader
venv/bin/behave --lang=zh-CN -f json.pretty -o './test_report.json'

/Users/wan/PycharmProjects/Downloader/report

#!/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"

  • 15
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值