在pytest框架中的另一个测试用例中调用测试用例 [英] invoking test case with in another test case in pytest framework
本文介绍了在pytest框架中的另一个测试用例中调用测试用例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 pytest 进行自动化.
I am using pytest for automation.
pytest 中是否有任何选项可以在另一个测试用例中调用测试用例.
Is there any option in pytest to invoking test case with in another test case.
推荐答案
当然可以.使用 pytest,测试用例是一个简单的函数或方法.
Sure you can. With pytest, a test case is a simple function or method.
例如:
def test_foo():
assert 2 + 2 == 4
def test_bar():
assert [1] + [2] == [1, 2]
test_foo()
考虑一下您为什么要这样做.通常,保持测试解耦会带来好处,例如在测试失败时更容易调试.
Consider why you would want to do this. Typically, keeping tests decoupled provides benefits, like easier debugging when a test fails.
这篇关于在pytest框架中的另一个测试用例中调用测试用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文