链接:http://tungwaiyip.info/software/HTMLTestRunner.html
因为是 2.7 版本的,我的 python 环境是 3.5,在网上查资料做了如下修改
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
import unittest
import os
from random import randint
from appium import webdriver
from time import sleep
import HTMLTestRunner
import time
class AimeiiOSTests(unittest.TestCase):
def setUp(self):
# set up appium
app = os.path.abspath('/Users/XXX/Library/Developer/Xcode/DerivedData/AIMEI-ayfhazejcwlpjnfdiwhdoozhqxlg/Build/Products/Debug-iphonesimulator/AIMEI.app')
self.driver = webdriver.Remote(
command_executor = 'http://127.0.0.1:4723/wd/hub',
desired_capabilities = {
'app':app,
'platformName':'iOS',
'platformVersion':'9.3',
'deviceName':'iPhone 6s'
})
def tearDowm(self):
self.driver.quit()
# 使用tap通过坐标来点击
def test_click(self):
self.driver.tap([(150, 620)])
self.driver.tap([(50, 620)])
self.driver.tap([(350, 620)])
self.driver.tap([(7, 35)])
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(AimeiiOSTests)
timestr = time.strftime('%Y-%m-%d %X', time.localtime(time.time()))
filename = '/Users/XXX/Desktop/TestResult/' + timestr + '.html'
fp = open(filename, "wb")
runner = HTMLTestRunner.HTMLTestRunner(
stream = fp,
title = u"TestReport",
description = u"Result"
)
unittest.TextTestRunner(verbosity = 2).run(suite)
fp.close()
代码运行正常,没有报错,测试用例也实现了,但是生成的.html 文件内容为空,请教一下各位以上哪里出错了?