文档结构
-project
--test_file
---file1
----test_1.py
----test_2.py
---file2
----test_3.py
----test_4.py
---file3
----test_5.py
----test_6.py
--one.py
下面是one.py的内容
# coding=utf-8
from unittest.runner import TextTestRunner
from unittest.suite import TestSuite
from unittest.loader import TestLoader
if __name__ == '__main__':
dir1 = "test_file/file1"
dir2 = "test_file/file2"
dir3 = "test_file/file3"
test_dirs = list()
test_dirs.append(dir1)
test_dirs.append(dir2)
test_dirs.append(dir3)
suite = TestSuite()
for item in test_dirs:
discover = TestLoader().discover(start_dir=item)
suite.addTest(discover)
runner = TextTestRunner(verbosity=2)
runner.run(suite)