例子:
class iBer(Unittest.TestCase):
@classmethod
def setUpClass(cls):
logger=public.log()
desired_caps = {
'platformName': 'Android',
'deviceName': '127.0.0.1:62001',
'platformVersion': '4.4.2',
'appPackage': 'com.ibroker.iBerHK',
'appActivity':'com.ibroker.iBerHK.MainActivity'
}
cls.dr = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps)
@classmethod
def tearDownClass(cls):
cls.dr.quit()
def test_XX002(self): #这个是测试用例
pass
if __name__ =="__main__":
testunit=unittest.TestSuite()
#添加测试用例到测试套件中
testunit.addTest(iBer("test_XX002"))
#定义个报告存放路径
filename = '/Users/kaibinliu/Desktop/appium automation/Android/LUCAX/report'
fp = file(filename, "wb")
#定义测试报告
runner =HTMLTestRunner.HTMLTestRunner(
stream=fp,
title=u'iBer测试报告',
description=u'用例执行情况:')
# 运行测试用例
runner.run(testunit)
#关闭报告文件
fp.close()
后记:
有个 'noReset': True 的参数设置,不知道是不是 启动应用的时候,不要重置应用的功能,还没有试,试了 不行
后面看了一篇博客,貌似这个参数是控制app要不要重新安装的
https://www.cnblogs.com/smallTestKK/p/5412702.html
顺便追加2个参数
#不需要再次签名
desired_cups['noSign'] = 'True'
#不需要清理数据,避免重新安装的问题
desired_cups['noReset'] = 'True'