我们如何控制 Python 鼻子测试中函数执行的顺序
How can we control the sequence of function execution in Python Nose test
在 python
的 Nose 测试场景中
class test_class(testcase):
def test_a(self):
print 'test1'
def test_b(self):
print 'test2'
def test_c(self):
print 'test3'
当我执行 nosetest 时,执行顺序不断变化。
有人可以建议如何provide/define执行此执行的顺序。
提前致谢..
-Revant
这是设计使然。 Nose 每次都会 运行 以随机顺序进行测试,并且不保证它们 运行 的顺序。您可以提供一个 setup
方法,该方法将 运行 在所有测试之前在 class 中,还有一个 teardown
方法,在 class 中的所有测试之后将 运行。
这个想法是孤立地测试系统中的每一件事,而不是让以前测试的结果影响其他测试。如果您需要订购测试,则表明您需要重构测试。
在 python
的 Nose 测试场景中class test_class(testcase):
def test_a(self):
print 'test1'
def test_b(self):
print 'test2'
def test_c(self):
print 'test3'
当我执行 nosetest 时,执行顺序不断变化。 有人可以建议如何provide/define执行此执行的顺序。
提前致谢..
-Revant
这是设计使然。 Nose 每次都会 运行 以随机顺序进行测试,并且不保证它们 运行 的顺序。您可以提供一个 setup
方法,该方法将 运行 在所有测试之前在 class 中,还有一个 teardown
方法,在 class 中的所有测试之后将 运行。
这个想法是孤立地测试系统中的每一件事,而不是让以前测试的结果影响其他测试。如果您需要订购测试,则表明您需要重构测试。