How to add test status in automation test in Pytest on LambdaTest
If you want to add test status in automation test in Pytest on LambdaTest, you can follow the below steps. You can refer to sample test repo here.
The driver function in conftest.py
has to add "lambda-status" as "passed" or "failed" based on the execution. Add the below code to your driver function (refer to conftest.py
):
def fin():
#browser.execute_script("lambda-status=".format(str(not request.node.rep_call.failed if "passed" else "failed").lower()))
if request.node.rep_call.failed:
browser.execute_script("lambda-status=failed")
else:
browser.execute_script("lambda-status=passed")
browser.quit()
request.addfinalizer(fin)
cd tests //navigate to tests directory
python sample_todo.py