unittest快速装载目前下所有测试用例的方法

 import unittest
from BeautifulReport import BeautifulReport    #导入BeautifulReport

if __name__ == '__main__':
  suite_tests = unittest.defaultTestLoader.discover(".",pattern="*tests.py",top_level_dir=None)     #"."表示当前目录,"*tests.py"匹配当前目录下所有tests.py结尾的用例
  BeautifulReport(suite_tests).report(filename='百度测试报告', description='搜索测试', log_path='.')    #log_path='.'把report放到当前目录下


参考: https://www.cnblogs.com/cnkemi/p/9052930.html

猜你喜欢

转载自www.cnblogs.com/kaibindirver/p/11439293.html