python并行跑两个case_Python+HTMLTestrunner批量执行case

#!/usr/bin/env python

# -*- coding: utf-8 -*-

# @Time : 2018/11/14 3:37 PM

# @Author : jiayu.chen

import os

import sys

import unittest

import HTMLTestRunner

import time

sys.path.append(os.path.abspath('..'))

from utils import zip_dir

from conf.sysconfig import doc_path_conf

from utils.send_email import SendMail

# 定义需要执行的用例文件夹

test_dir = doc_path_conf.settle_case_path

# 获取测试套件,pattern参数表示被执行文件的规则

suite = unittest.defaultTestLoader.discover(start_dir=test_dir, pattern='test*.py')

def run():

'''

执行目标文件夹中所有以test开头.py结尾的测试用例

:return:

'''

now = time.strftime('%Y-%m-%d_%H_%M_%S')

reportname = doc_path_conf.report_path + '/' + now + 'SettleSingleTestResult' + '.html' # 定义报告的名称和路径

with open(reportname, 'wb') as f:

runner = HTMLTestRunner.HTMLTestRunner(

stream=f,

title='测试报告',

description='结算系统单功能测试用例'

)

runner.run(suite)

f.close()

# 压缩目标路径中的所有文件到zip包

zip_dir.ZipDir(doc_path_conf.screenshot_path, doc_path_conf.output_path + '/' + now + '_img.zip')

time.sleep(3)

# 发送邮件,设置邮件主题

mail = SendMail(subject="结算系统单功能测试用例")

mail.send()

if __name__ == '__main__':

run()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值