fundakol / pytest-jira-xray

Plugin for pytest to upload test results to JIRA XRAY
Apache License 2.0
27 stars 18 forks source link

Import result error x-ray cloud when using test title #86

Open addymeni opened 1 year ago

addymeni commented 1 year ago

The test cases I write need to have a title to be displayed on the html report file and hence I add the description inside the function between ''' ......''' like mentioned below.

@pytest.mark.xray('ABC-704') def test_foo(): '''Check Login Functionality''' ....... assert True

I have a hook that appends that summary as the title of the test in report

@pytest.hookimpl(hookwrapper=True) def pytest_runtest_makereport(item, call): outcome = yield report = outcome.get_result() test_fn = item.obj docstring = getattr(test_fn, '--doc--') if docstring: report.nodeid = docstring

This will append that information as title of the test case in the report which is more readable rather than displaying function name.

But if I use this then the API is not able to import. I get the error :

Could not publish results to Jira XRAY! HTTPError: Could not post to JIRA service at https://xray.cloud.getxray.app/api/v2/import/execution. Response status code: 400 Error message from server: Result is not valid Xray Format

The error is gone and the execution result is imported fine when I remove the '''....''' .

Is there a way to allow this and still be able to import ?

fundakol commented 1 year ago

nodeid is a unique identifier for test item in pytest. Xray plugin uses it to keep information about all tests with Xray decorator. If you change nodeid before xray report is generated it won't work.

Error message Result is not valid Xray Format is not clear to me without having a report which you sent. You can try to save an Xray report to a file and attach to the issue.

addymeni commented 1 year ago

This is the report that doesn't work and gives the above posted error :

image

This is the report that works, when I remove the '''Login Functionality''' / comment out the pytest_runtest_makereport hook that I created

<TestReport 'testcases/QA/test_loginmodule.py::test_foo' when='setup' outcome='passed'>

fundakol commented 1 year ago

As I wrote it won't work if you change nodeid.

addymeni commented 1 year ago

Is there an alternate way to accommodate the test title change?