zoukankan      html  css  js  c++  java
  • appium+jenkins自动化集成

    1、linux 服务器上安装python、jdk、appium、nodejs、Android SDK 、Jenkins、Allure、Allure Commandline等

    AndroidSDK安装:https://blog.csdn.net/qq_40308101/article/details/108578650

    appium 安装:https://blog.csdn.net/vensers/article/details/105955197

    allure 安装:https://blog.csdn.net/bang152101/article/details/108874136

    Jenkins安装:https://blog.csdn.net/linkingfei/article/details/105309076

    2、Jenkins 配置截图

    脚本执行代码:

    # -*- coding: utf-8 -*
    import os
    import shutil
    import subprocess
    import time
    from pylib import Log
    from pylib import commonlib
    import pytest
    
    PATH = os.path.split(os.path.realpath(__file__))[0]
    xml_report_path = PATH + "/report/xml"
    html_report_path = PATH + "/report/html"
    commonlib.create_dir_not_exist(xml_report_path)
    commonlib.create_dir_not_exist(html_report_path)
    
    tm = time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime(time.time()))
    
    def invoke(md):
        output, errors = subprocess.Popen(md,
                                          shell=True,
                                          stdout=subprocess.PIPE,
                                          stderr=subprocess.PIPE).communicate()
        o = output.decode("utf-8")
        return o
    
    if __name__ == '__main__':
    
        log = Log.MyLog()
        log.info(
            f"---------------------------START: {tm}------------------------------")
        shutil.rmtree(xml_report_path)
        # 获取外部传参
        if os.environ['opt'] == 'new':
            args = ['-s', '-q','-k','test_alipay_new_buyTicket_DES','--instafail', '--tb=line', '--alluredir', xml_report_path]
        elif os.environ['opt'] == 'old_all':
            args = ['-s', '-q', '-k', 'oldTicket', '--instafail', '--tb=line', '--alluredir',xml_report_path]
        elif os.environ['opt'] == 'other':
            args = ['-s', '-q', '-k', 'test_other_applet_buyTicket', '--instafail', '--tb=line', '--alluredir',xml_report_path]
        elif os.environ['opt'] == 'old_des':
            args = ['-s', '-q', '-k', 'test_buyTicket_DES', '--instafail', '--tb=line', '--alluredir',xml_report_path]
        elif os.environ['opt'] == 'old_sec':
            args = ['-s', '-q', '-k', 'test_buyTicket_SEC', '--instafail', '--tb=line', '--alluredir', xml_report_path]
        elif os.environ['opt'] == 'old_appoint':
            args = ['-s', '-q', '-k', 'test_appointTicketSec', '--instafail', '--tb=line', '--alluredir', xml_report_path]
        else:
            args = ['-s', '-q', '--instafail', '--tb=line', '--alluredir', xml_report_path]
        # 运行上次失败用例
        # args = ['-s','-q','--lf','--alluredir', xml_report_path]
        pytest.main(args)
        cmd = 'allure generate %s -o %s --clean' % (xml_report_path,
                                                    html_report_path)
        invoke(cmd)
        log.info(
            f"-----------------------------END: {tm}-------------------------------")    
    脚本执行代码

     

     构建命令代码:

    echo ${opt}
    HOME=/home/aut
    source /etc/profile
    source /home/aut/.bashrc
    pyenv activate ${JOB_NAME}
    pip install -r requirements_linux.txt -i https://mirrors.aliyun.com/pypi/simple
    python run.py ${opt}
    curl -H "Content-Type:application/json" -H "authorization:" -X POST --data '{ "job": "'${JOB_NAME}'", "build":'${BUILD_NUMBER}'}' http://192.168.10.XX:5000/aut/sentReport

     后台启动appium:

    nohup appium > appium.log 2>&1 &

    python 用例执行失败,触发Jenkins构建失败

    链接:https://www.pythonheidong.com/blog/article/319258/5dd210e741d49e1fa45a/

  • 相关阅读:
    Linux下通过二进制方式安装mysql5.7版本和系统优化
    SQL中的real、float、decimal、numeric数据类型区别
    SQL中的事务ACID
    一台服务器搭建部署两个或多个Redis实例
    SQLServer数据库镜像高性能模式下维护
    SQLServer配置镜像,无法将 ALTER DATABASE 命令发送到远程服务器实例,数据库镜像配置未更改。请确保该服务器已连接,然后重试。
    阿里云数据库MongoDB版清理oplog日志和compact命令详解
    Linux下shell脚本实现mongodb定时自动备份
    List分组
    Sql Server日期查询-SQL查询今天、昨天、7天内、30天
  • 原文地址:https://www.cnblogs.com/aiyumo/p/14428699.html
Copyright © 2011-2022 走看看