class BaseTest():
def teabc(self,i):
print(“BaseTest中的 i”)
print(i)
class ParameTestCase01(unittest.TestCase):
def init(self,methodName=‘runTest’,parame=None):
super(ParameTestCase01,self).init(methodName)
global parames
parames=parame
print(parames)
class MyTestCase005(ParameTestCase01):
@classmethod
def setUpClass(cls):
print("setUpclass---->"+str(parames))
bb=BaseTest()
bb.teabc(parames)
def setUp(self):#准备的过程
print("setUp")
def test_01(self):#执行的过程,以test开头的测试用例
time.sleep(10)
self.assertTrue(True)
def test_02(self): # 执行的过程,以test开头的测试用例
self.assertTrue(True)
def tearDown(self):#清理的过程
# self.driver.quit()
print("tearDown")
@classmethod
def tearDownClass(cls):
print('tearDownCls')
def get_now_time():
ts = time.time()
dt = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ts))
# dt=time.strftime("%Y-%m-%d", time.localtime(ts))
dt = time.strftime("%Y-%m-%d_%H%M%S", time.localtime(ts))
dt = time.strftime("%Y%m%d_%H%M%S", time.localtime(ts))
return dt
def get_suite(i):
print(“get_suite里面的”, i)
test_dir = sys.path[0]
suite = unittest.TestSuite()
#suite.addTest(MyTestCase005("test_01", parame=i))
#suite.addTest(MyTestCase005("test_02", parame=i))
suite = unittest.defaultTestLoader.discover(test_dir, pattern='pytest*.py')
# unittest.TextTestRunner().run(suite)
# html_file = "E:/Teacher/Imooc/AppiumPython/report/report" + str(i) + ".html"
#
pfilename = os.path.basename(sys.argv[0]).split(".")[0]
filename = 'D:/workplace/pycharm/Wholebraintest/report/'+str(i)+ pfilename + get_now_time() + '.html'
fp = open(filename, "wb")
# HTMLTestRunner.HTMLTestRunner(stream=fp, title="alan测试报告", description="用例测试情况").run(suite)
HTMLTestReportCN.HTMLTestRunner(stream=fp, title="alan测试报告", description="用例测试情况").run(suite)
fp.close()
if name == ‘main’:
print(“haha”)
threads = []
for i in range(3):
print(i)
t = multiprocessing.Process(target=get_suite, args=(i,))
threads.append(t)
for j in threads:
j.start()
在用例比较多的时候
我 get_suite()里面 如果想用 suite = unittest.defaultTestLoader.discover(test_dir, pattern=‘pytest*.py’) 这种方法 不用 suite.addTest(MyTestCase005(“test_02”, parame=i)) 这种 那么 参数 i 该怎么传?