[英]How can we control the sequence of function execution in Python Nose test
In a scenario of Nose tests in python 在python中进行鼻子测试的情况下
class test_class(testcase):
def test_a(self):
print 'test1'
def test_b(self):
print 'test2'
def test_c(self):
print 'test3'
when i execute the nosetest, the sequence of execution keep changing. 当我执行鼻子测试时,执行顺序不断变化。 Could some one please advise on how to provide/define a sequence for this execution.
有人可以建议如何为执行提供/定义一个序列。
Thanks so much in advance.. 非常感谢。
-Revant -Revant
That is by design. 那是设计使然。 Nose will run the tests in random order each time and makes no guarantees of the order they will run in. You can provide a
setup
method that will run before all tests in that class, and a teardown
method that will run after all tests in that class. Nose每次都会以随机顺序运行测试,并且不能保证它们将按其运行顺序。您可以提供将在该类中的所有测试之前运行的
setup
方法,以及将在该类中的所有测试之后运行的teardown
方法。类。
The idea is to test each thing in a system in isolation, and not have results from previous tests affect other tests. 这个想法是孤立地测试系统中的每件事,并且先前测试的结果不会影响其他测试。 If you need the tests to be ordered, then it's a sign that you need to refactor your tests.
如果您需要订购测试,则表明您需要重构测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.