MaY*_*HEM 5 pytest python-2.7 pytest-django
我正在使用 pytest 进行自动化。
pytest 中是否有任何选项可以在另一个测试用例中调用测试用例。
Fra*_*k T -1
你当然可以。对于 pytest,测试用例是一个简单的函数或方法。
例如:
def test_foo():
assert 2 + 2 == 4
def test_bar():
assert [1] + [2] == [1, 2]
test_foo()
Run Code Online (Sandbox Code Playgroud)
考虑一下您为什么要这样做。通常,保持测试解耦会带来好处,例如在测试失败时更容易进行调试。
| 归档时间: |
|
| 查看次数: |
5953 次 |
| 最近记录: |