如果测试用例发现错误,请停止测试套件 [英] Stop testsuite if a testcase find an error

查看:140
本文介绍了如果测试用例发现错误,请停止测试套件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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.

这篇关于如果测试用例发现错误,请停止测试套件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆