import sys
sys.path.append(“C:/Users/Administrator/PycharmProjects/AppiumPython”)
import unittest
import HTMLTestRunner
import threading
import multiprocessing
import time
from util.server import Server
from appium import webdriver
from business.login_business import LoginBusiness
from util.write_user_command import WriteUserCommand
class ParameTestCase(unittest.TestCase):
def init(self, methodName=‘runTest’, parame=None):
super(ParameTestCase, self).init(methodName)
global parames
parames = parame
class CaseTest(ParameTestCase):
@classmethod
def setUpClass(cls):
# capabilities = {
# “platformName”: “Android”,
# “deviceName”: “2197aa0d”,
# “app”: “C:\Users\Administrator\Desktop\WYClient\doctor_C148_V3.8.1_b201912120959_release_Assistant\doctor_C148_V3.8.1_b201912120959_release_Assistant_guahao.apk”,
# “appWaitActivity”: “com.greenline.yihuantong.guide.GuideActivity”
# }
# driver = webdriver.Remote(“http://127.0.0.1:4723/wd/hub”, capabilities)
# time.sleep(2)
# print(“this is class”)
print(‘setUpclass---->’, parames)
cls.login_business = LoginBusiness(parames)
def setUp(self):
print("this is setup\n")
def test_01(self):
self.login_business.changtab()
# print("this is case01")
# self.assertEqual("1","1")
print('Test Case 里面的参数', parames)
# @unittest.skip("CaseTest")
#def test_02(self):
# print("this is case02\n")
def tearDown(self):
time.sleep(1)
print("this is teardown\n")
@classmethod
def tearDownClass(cls):
time.sleep(1)
print("this is class teardown\n")
def appium_init():
server = Server()
server.main()
def get_suite(i):
# unittest.main()
print(“get_suite里面的”,i)
suite = unittest.TestSuite()
suite.addTest(CaseTest(“test_01”, parame=i))
# suite.addTest(CaseTest(“test_02”, parame=i))
unittest.TextTestRunner().run(suite)
# html_file = “C:/Users/Administrator/PycharmProjects/AppiumPython/report/report.html”
# fp = open(html_file,“wb”)
# HTMLTestRunner.HTMLTestRunner(stream=fp).run(suite)
def get_count():
write_user_file = WriteUserCommand()
count = write_user_file.get_file_lines()
return count
if name == ‘main’:
appium_init()
threads = []
for i in range(get_count()):
print(i)
t = multiprocessing.Process(target=get_suite, args=(i,))
threads.append(t)
for j in threads:
j.start()
time.sleep(2)
执行testcase1时,第一次会出现下面的情况,再执行一次就正常执行了,是不是刚开始adb devices没获取到设备?