如果测试用例发现错误,请停止测试套件

如果测试用例发现错误,请停止测试套件

问题描述:

我在Python中有一个testSuite,其中有几个testCases.

I have a testSuite in Python with several testCases.

如果testCase失败,则testSuite继续下一个testCase.我希望能够在testCase失败时停止testSuite,或者能够决定testSuite应该继续还是停止.

If a testCase fails, testSuite continues with the next testCase. I would like to be able to stop testSuite when a testCase fails or be able to decide if the testSuite should continue or stop.

自python 2.7起,unittest支持failfast选项.可以通过命令行指定:

Since Python 2.7, unittest support failfast option. It can be either specified by commandline:

python -m unittest -f test_module

或使用脚本时:

>>> from unittest import main
>>> main(module='test_module', failfast=True)

不幸的是,当您使用setuptoolssetup.py时,我尚未发现如何指定此选项.

Unfortunately I haven't yet found out how to specify this option when you are using setuptools and setup.py.