I am trying to run my tests in parallel mode using ThreadPoolExecutor, here is my Runner class
suite = unittest.TestSuite()
if (options == 'by_method'):
for object in name:
for method in dir(object):
if (method.startswith('test')):
suite.addTest(object(method))
with ThreadPoolExecutor(max_workers=devicesList.__len__()) as executor:
list_of_suites = list(suite)
for test in range(len(list_of_suites)):
test_name = str(list_of_suites[test])
try:
executor.submit(unittest.TextTestRunner(verbosity=2).run, list_of_suites[test])
except:
pass
And this is my test class
import unittest
class Runner(unittest.TestCase):
@classmethod
def setUpClass(self):
print("setup method")
def test_deeplinks(self):
print("test1")
def test(self):
print("test2");
def test4(self):
print("test 4")
def test5(self):
print("test5");
@classmethod
def tearDownClass(self):
print("tear down ")
if __name__ == '__main__':
# runner = Runner.Runner()
# runner.parallel_execution(Runner, TestDeeplinks)
suite = unittest.TestLoader().loadTestsFromTestCase(Runner)
unittest.TextTestRunner(verbosity=2).run
but my setupClass method is not getting called can anyone please tell what i'm doing here
Maybe you need to use setUp()
instead of setUpClass()
setUpClass()
only runs once per whole class
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.