自己写了一个测试框架,在多用例执行的时候每次,执行成功目录的第一个用例后,后面的用例均失败。
D:\AUTOMEDLINKER
├─.idea
├─apk
├─common
├─log
├─medcases
│ ├─ChannelTest
│ ├─HeadlineTest
│ └─LoginTest
├─report
└─screenshot
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by nil_mmm
import unittest
import HTMLTestRunner
import time
# 配置Case的路径
case_dir = [
'LoginTest',
'ChannelTest']
# 配置报告名称
filename = "D:/automedlinker/report/" + time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time())) + ".html"
# 配置报告标题
report_title = 'Auto Case Report'
# 配置报告描述
report_description = ' '
if __name__ == '__main__':
suite = unittest.TestSuite()
for cases in case_dir:
cases = unittest.defaultTestLoader.discover(cases, pattern='*Test.py', top_level_dir='medcases')
suite.addTests(cases)
fp = file(filename, 'wb')
#使用 HTMLTestRunner 配置参数,输出报告路径、报告标题、描述
runner = HTMLTestRunner.HTMLTestRunner(stream=fp, title=report_title, description=report_description)
runner.run(suite)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by nil_mmm
import unittest
import android_caps
import traceback
from common import Main
from common import GetScreen
from common import UserLogin
class Case(unittest.TestCase):
def setUp(self):
self.driver = android_caps.my_driver
print '第一个用例检测'
def tearDown(self):
self.driver.quit()
def test_first(self):
try:
UserLogin.jump_session_page()
print '进入搜索界面'
Main.get_resource_id('tv_search').click()
Main.get_resource_id('et_search_action').send_keys('test')
print '搜索test'
Main.get_resource_id('tv_search').click()
Main.get_resource_id('tv_title')
except:
GetScreen.get_screenshot(self.driver,'test')
traceback.print_exc()
self.fail()