并发运行,i参数传不过去
来源:5-12 多线程、unittest、启动服务逻辑串联

tammy212
2019-07-17
#coding=UTF-8
import unittest
import HTMLTestRunner
import threading
from util.server import Server
from appium import webdriver
from base.base_driver import BaseDriver
from business.login_business import LoginBusiness
class ParameTestCase(unittest.TestCase):
'''
methodName="runTest"是unittest.TestCase的构造方法
'''
def __init__(self,methodName="runTest",param=None):
super(ParameTestCase,self).__init__(methodName)
self.param=param
# global params
# params=param
class TestCase(ParameTestCase):
'''
这个是全局的方法,跑所有case之前运行一次
'''
@classmethod
def setUpClass(cls) :
# global params
print("this is setUpClass")
# cls.login_business=LoginBusiness(i)
@classmethod
def tearDownClass(cls):
print ("this is teardown")
'''
跑每个case都要运行一次
'''
def setUp(self):
print ("this is setUp"+str(self.param))
def tearDown(self):
print ("this is teardown")
def test01(self):
print ("testcase"+str(self.param))
def get_suite(i):
suit = unittest.TestSuite()
suit.addTest(TestCase("test01", param=i))
unittest.TextTestRunner().run(suit)
# html_file = "/Users/tammy/tammy/workspace_python/appiumPython/report/report"+str(i)+".html"
# fp = file(html_file, "wb")
# HTMLTestRunner.HTMLTestRunner(fp).run(suit)
def appium_init():
'''
启动服务
:return:
'''
server = Server()
server.main()
if __name__ =="__main__":
threads = []
for i in range(2):
print (i)
t = threading.Thread(target=get_suite, args=(i,))
threads.append(t)
for j in threads:
j.start()
运行之后参数i一直传不过去
写回答
1回答
-
Mushishi
2019-07-18
你先在父类里面打印,你看你能打印么,你再想父类到下面
022019-07-21
相似问题