Riadayal / Pytest-add-status

A sample repo to help you add test status in automation test in Pytest on LambdaTest. Run your automation test in Pytest on LambdaTest.

Home Page:https://www.lambdatest.com/pytest-testing/?utm_source=github&utm_medium=about&utm_campaign=pytest_add_status

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

Configure conftest.py

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)

Run your test

cd tests //navigate to tests directory
python sample_todo.py

Links:

LambdaTest Community