Android App自动化测试框架【二】

本文为博主原创,未经许可严禁转载。
本文链接:https://blog.csdn.net/zyooooxie/article/details/113873769

前面分享了 App自动化测试框架【一】;现继续更新;

这是 App自动化测试的 category ,有兴趣 可以看看。

个人博客:https://blog.csdn.net/zyooooxie

需求

本期主要讲述:

在这里插入图片描述

生成测试报告

File:run_app.py


def run_main():
    # case_path_1 = os.path.join(case_path, 'test_test.py')

    py_list = ['-v', case_path, '--alluredir', allure_path, '--clean-alluredir', '--reruns', '1', '--reruns-delay', '5']
    pytest.main(py_list)

    # allure的environment.properties文件 会被清理掉
    with open(os.path.join(allure_path, 'environment.properties'), 'w') as f:
        w_str = 'Python.Version=3.6\nAuthor:xzc'
        f.write(w_str)

    allure_bat_path = r'C:\allure-2.7.0\bin\allure.bat'
    allure_cmd = "%s generate %s -o %s -c" % (allure_bat_path, allure_path, html_path)
    os.system(allure_cmd)

发送测试邮件【163邮箱】

@File:practice_email.py
使用的是 yagmail



def send_email():
    # qq邮箱、163邮箱 下面2行 通用;
    email = yagmail.SMTP(user=gl_acc, password=gl_pwd, host=gl_server, encoding='gbk')
    # email = yagmail.SMTP(user=gl_acc, password=gl_pwd, host=gl_server, encoding='gbk', smtp_ssl=True)

    subject = '重要通知:报告,随机码:{}'.format(random.randint(10000, 99999))
    content = ['Tester:{} (虚假) 已经完成测试'.format(f.name())]
    Log.info(subject)
    Log.info(content)

    # 最好不要使用相对路径的.
    file = [r'D:\0128postman.csv', r'D:\物业3.PNG', os.path.join(gl_par_path, '__init__.py'), os.path.join(gl_config_ini_path, 'config.ini')]

    email.send(to=gl_receiver, subject=subject, contents=content, attachments=file, cc=gl_cc)
    Log.info('邮件发送成功')
    email.close()

企微机器人发通知

File:practice_qw_robot.py


def send_msg(text, key='zyooooxie-zyooooxie-zyooooxie-zyooooxie-zyooooxie'):
    url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=' + key
    data_dict = {
    
    'msgtype': 'text', 'text': {
    
    'content': text}}
    res = requests.post(url=url, json=data_dict)
    assert res.json().get('errmsg') == 'ok'
    Log.info(f'{text}')
    print('企微通知完成')


Jenkins邮件通知【qq邮箱】

使用Email Extension Plugin 插件

在这里插入图片描述

Triggers 建议设置为 Always:

在这里插入图片描述

结果展示

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

这一篇主要的内容就这些;因为我是为了练习,写个demo;

交流技术 欢迎+QQ 153132336 zy
个人博客 https://blog.csdn.net/zyooooxie

猜你喜欢

转载自blog.csdn.net/zyooooxie/article/details/113873769