1、此鈎子函數在測試用例運行的不同階段(setup, call, teardown)都會被調用一次
def pytest_runtest_makereport(item, call): """
返回一個_pytest.runner.TestReport類對象
每個測試用例執行后,制作測試報告 :param item:測試用例對象 :param call:測試用例的測試步驟, _pytest.runner.CallInfo對象 先執行when=’setup’ 返回setup 的執行結果 然后執行when=’call’ 返回call 的執行結果 最后執行when=’teardown’返回teardown 的執行結果 :return: """ print(item) print(call) print(call.when) print(call.result)
2、執行結果
testcase/test_getRegionCountry/test_GetRegionCountry.py::test_getRightrequest <Function test_getRightrequest> <CallInfo when='setup' result: []> setup [] <Function test_getRightrequest> <CallInfo when='call' result: []> call [] PASSED<Function test_getRightrequest> <CallInfo when='teardown' result: []> teardown []