代码:
# -*- coding: utf-8 -*-
import unittest
from time import sleep, strftime
import os
import HTMLTestRunner
from appium import webdriver
from ddt import ddt, data, unpack
@ddt
class ddtTest(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
@data([1],[2])
@unpack
def test_LoginByAccount(self, city):
print(city)
if __name__ == '__main__':
# 创建测试报告存放目录
try:
os.mkdir('..\Report')
except Exception as e:
pass
#测试套件实例化
suite = unittest.TestLoader().loadTestsFromTestCase(ddtTest)
runner = HTMLTestRunner.HTMLTestRunner(title="ddt测试报告", description="测试情况", stream=open(
"..\Report\登录测试报告_%s.html" % strftime("%Y%m%d_%H%M%S"), "wb"), verbosity=2,retry=0, save_last_try=True)
runner.run(suite)
测试报告:
问题:
使用ddt数据驱动,会使得测试例子名称,出现未知错误,求如何解决,百度与谷歌关于此类的答案仍未给出,望广大博友伸出援手,不胜感激