Bhavesh Lad
Bhavesh Lad

Reputation: 5

Pytest Testrail Module - Post Test Results for Test Runs

I am trying to use the pytest testrail module and started with this demo script:

import pytest
from pytest_testrail.plugin import testrail

@testrail('C165')
def test_run():
    print "T165:pass"

It does create a test run but does not post any results to the corresponding test cases.

Upvotes: 0

Views: 2338

Answers (2)

thuantp J
thuantp J

Reputation: 13

Here is add_result function. The testrail plugin executes it when your test (test_run) is finished.

You can notice the parameter status in the function, it requires your test need to return the result from assertion (ex. assert False is good example).

In your case, just print a string is not good to testrail know the status of the test.

def add_result(self, test_ids, status, comment='', duration=0):
    """
    Add a new result to results dict to be submitted at the end.

    :param list test_ids: list of test_ids.
    :param int status: status code of test (pass or fail).
    :param comment: None or a failure representation.
    :param duration: Time it took to run just the test.
    """

Upvotes: 0

dubner
dubner

Reputation: 11

Try adding an assertion as that is what the pytest hook is looking for:

import pytest
from pytest_testrail.plugin import testrail

@testrail('C165')
def test_run():
    assert False

Upvotes: 1

Related Questions