厕所

coding=utf-8

import unittest
import sys
sys.path.append(r’./ars’)
from common import HTMLTestRunner
import os,time

from apscheduler.scheduler import Scheduler

from common import mailutil

from conf import config
import logging
logging.basicConfig()

”’
参数配置
”’
script_prefix = ‘test’ #脚本名称前缀

testcase_excle_path = r”E:\workspace\ATF\src\wifi.xlsx” #测试用例所在的路径

version = ‘PayGateway V1.0.0’ #项目版本信息
caselist = r’./ars’ #测试脚本所在的目录

def createSuite(pattern):
testunit = unittest.TestSuite()
discover = unittest.defaultTestLoader.discover(caselist, pattern=pattern, top_level_dir=None)
#discover 方法筛选出来的用例,循环添加到测试套件中
for test_suite in discover:
for test_case in test_suite:
testunit.addTests(test_case)
return testunit

def runtest():
alltestname = createSuite(script_prefix+”*.py”)

now = time.strftime('%Y-%m-%d-%H_%M_%S',time.localtime(time.time()))

reportpath = os.getcwd().split("testcase")[0] + "\\report\\"
#判断report目录是否存在
if (os.path.exists(reportpath)) != True:
    os.makedirs(reportpath)

filename = reportpath+now+"_result.html"
fp = file(filename,'wb')

title = version + u"测试报告"
runner = HTMLTestRunner.HTMLTestRunner(
    stream=fp,
    title=title,
    description=u'用例执行情况:',

execelfile =testcase_excle_path,

version=version

)
#执行测试用例
runner.run(alltestname)

#发送邮件

subject = title

mailutil.sendEmail(config.authInfo, config.fromAdd, config.toAdd,

config.ccAdd, subject, config.plainText,

filename, filename)

if name == ‘main‘:
runtest()

sched = Scheduler()

sched.daemonic = False

#定时执行

sched.add_cron_job(runtest,day_of_week=’mon-sat’, hour=’‘, minute=’‘,second=’*/30’)

sched.start()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值