python unittest装载、执行、造成报告
#执行用例
caselist = config.caselist
for i in range(0,len(caselist)):
reportname = caselist[i][2:]
now = config.now
screenshotpath = config.screenshotpath
def creatsuitel():
os.mkdir(screenshotpath)
testunit=suite.Suit()
#discover 方法定义
discover=unittest.defaultTestLoader.discover(caselist[i],pattern ='test_*.py',top_level_dir=None)
#discover 方法筛选出来的用例,循环添加到测试套件中
for test_suite in discover:
for test_case in test_suite:
print(test_case)
testunit.addTests(test_case)
return testunit
alltestnames = creatsuitel()
report = config.reportpaht + reportname + now + '.html'
fp = open(report, 'wb')
runner =HTMLTestRunner.HTMLTestRunner(stream=fp,title=u'自动化测试报告',description=u'用例执行情况:')
#执行测试用例
runner.run(alltestnames)
fp.close()
#发送结果邮件,先压缩再发送
# zip.zip_compression(config.reportpaht, config.reportpaht + "report.zip")
# SentEmail.sentemail(config.reportpaht + "report.zip")
python unittest装载、执行、造成报告的更多相关文章
- Pycharm上python unittest不执行"if __name__ == '__main__' "问题or选择非unittest run
转:http://www.cnblogs.com/csjd/p/6366535.html python unittest不执行"if __name__ == '__main__' " ...
- 第二种方式,修改python unittest的执行顺序,使用猴子补丁
1.按照测试用例的上下顺序,而不是按方法的名称的字母顺序来执行测试用例. 之前的文章链接 python修改python unittest的运行顺序 之前写的,不是猴子补丁,而是要把Test用例的类名传 ...
- 一文搞懂Python Unittest测试方法执行顺序
大家好~我是米洛! 欢迎关注我的公众号测试开发坑货,一起交流!点赞收藏关注,不迷路. Unittest unittest大家应该都不陌生.它作为一款博主在5-6年前最常用的单元测试框架,现在正被pyt ...
- python unittest不执行"if __name__ == '__main__' "问题(Pycharm)
问题: 1.selenium导入unittest框架和HtmlReport框架后,HtmlReport不被执行. 2.IDE为Pycharm 假设代码为: from selenium import w ...
- Python Unittest模块测试执行
记录一下Unittest的测试执行相关的点 一.测试用例执行的几种方式 1.通过unittest.main()来执行测试用例的方式: if __name__ == "__main__&quo ...
- Python unittest 之 BeautifulReport可视化报告
众所周知的报告是HTMLTestRunner,虽然经过众多的大神修改后,功能挺强大的,但这颜值,我就不多说了,大家自己感受下吧 HTMLTestRunner就不多说了,近来发现了一款款式新颖,还不漏油 ...
- Python 同一文件中,有unittest不执行“if __name__ == '__main__”,不生成HTMLTestRunner测试报告的解决方案
1.问题:Python中同一个.py文件中同时用unittest框架和HtmlReport框架后,HtmlReport不被执行. 2.为什么?其实不是HtmlReport不被执行,也不是HtmlRep ...
- 现在都是python 单独开发框架 执行脚本,处理结果,发报告之类的
现在都是python 单独开发框架 执行脚本,处理结果,发报告之类的
- jmeter+python+sh执行优化报告(一)
缘由: 1)jmeter生成的html报告容量偏大 2)jmeter生成的报告,没有历史统计 3)此外,该目录整体可以整合的自动化平台内 故:做了调整~ 一.目录结构 1)scriptPy文件夹:主要 ...
随机推荐
- Spring重温(一)--Spring快速入门
1.spring官网(https://repo.spring.io)下载依赖jar. 2.配置spring环境时还需要commons-logging相关jar. 3.打开eclise创建一个工程,并将 ...
- java高级 - java利用listener实现回调,即观察者模式
https://blog.csdn.net/lin_sir6/article/details/70052954
- Iterables vs. Iterators vs. Generators
Reprinted from: Iterables vs. Iterators vs. Generators Occasionally I've run into situations of conf ...
- struts2框架之国际化(参考第二天学习笔记)
国际化 1. 回忆之前的国际化 1). 资源包(key=字符串) > 命名:基本名称+local部分.properties,res_zh.properties,res_zh_CN.propert ...
- tomcat session Memcache 共享
背景 这次做的这个项目并发还真是挺高,单表一天产生百万条记录不在话下.结果导致运行过程中经常丢失数据,卡.慢等.开来终于要搞一次负载均衡了,之前实验学习了不少,但是没有在项目中实际用过,因为并发量不大 ...
- spring3.1 profile 配置不同的环境
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...
- Zabbix3.2监控Windows的内存使用百分比并在内存使用率超过85%的时候触发报警
内存使用率key:vm.memory.size[pused]
- python学习第天14天。
模块 什么是模块 常见的场景:一个模块就是一个包含了python定义和声明的文件,文件名就是模块名字加上.py的后缀. 但其实import加载的模块分为四个通用类别: 1 使用python编写的代码( ...
- Laravel 5.2--如何让表单提交错误,不清空?
控制器 public function store(Request $request) { $validator = Validator::make($request->all(), [ 'Su ...
- Django 自定义模型管理器类2个应用场景
class BookManager(models.Manager): # 改变查询集的结果集 def all(self): books = super().all() # QuerySet books ...