整合所有测试用例文件xd

2021-04-07  本文已影响0人  Chaweys

all_test.py

#coding=utf-8
import HTMLTestRunner
import catagory,login_order
import unittest
import time
import sendmial

def create_suite():
    suite=unittest.TestSuite()
    #unittest.makeSuite(包名.类名)
    suite.addTest(unittest.makeSuite(catagory.CatagoryTest))
    suite.addTest(unittest.makeSuite(login_order.LoginOrderTest))
    return suite

if __name__ == '__main__':
    suite=create_suite()
    file_time=time.strftime("%Y%m%d-%H%M%S",time.localtime())
    file_path='./report/'+file_time+'_resutl.html'
    with open(file_path,'wb') as f:
        #执行用例结束后自动生成测试报告
        runner=HTMLTestRunner.HTMLTestRunner(stream=f,title='小滴课堂测试报告',description="demo报告测试")
        runner.run(suite)

    #调用发送邮件方法
    emailtest.SendMialTest.send_mail()

目录结构:
│  all_test.py     #主入口 
│  catagory.py     #菜单分类测试用例 
│  login_order.py  #登录下单测试用例
│  sendemil.py     #发送邮件封装
│  __init__.py
│
├─config
│      conf.ini
│
├─picture
├─report
│      20210405-123142_resutl.html
│      20210405-124253_resutl.html
│      20210405-124519_resutl.html


conf.ini配置文件内容:
[usercount]
username=18126403776
password=hdc@328216

[email]
mail_server=smtp.163.com
sender=hu_dechao@163.com
authcode=GOJFKYKNROMZWRZH
receivers=471260459@qq.com
上一篇下一篇

猜你喜欢

热点阅读