invoking test case with in another test case in pytest framework

时光总嘲笑我的痴心妄想 提交于 2021-02-08 05:08:33

问题


I am using pytest for automation.

Is there any option in pytest to invoking test case with in another test case.


回答1:


Sure you can. With pytest, a test case is a simple function or method.

For example:

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.



来源:https://stackoverflow.com/questions/45210365/invoking-test-case-with-in-another-test-case-in-pytest-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!