【发布时间】:2017-10-17 03:10:39
【问题描述】:
假设我有几个模块的测试用例源自unittest.TestCase。所有这些模块都位于一个包中test:
test/
test_case1.py
test_case2.py
test_case3.py
我想使用 one shell 命令在 test 的所有模块中运行 all 测试。为了做到这一点,我添加了一个新模块test_all.py,它创建了一个包含所有测试用例的TestSuite,以及main:
def make_suite():
... # add test cases explicitly one by one
if __name__ == "__main__":
suite = make_suite()
unittest.TextTestRunner().run(suite)
现在我想知道是否有一种方法可以运行 所有 test 中的测试用例,而无需创建 TestSuite
【问题讨论】:
-
你反对使用
nosetests这样的工具吗? -
是的,如果不是绝对必要的话。
标签: python unit-testing