allankp / pytest-testrail

pytest plugin for integration with TestRail, for creating testruns and updating results
MIT License
96 stars 124 forks source link

How to add testrail case id to parametrized multiple arguments? #77

Closed TomskDiver closed 5 years ago

TomskDiver commented 5 years ago

For simple test we make: @pytestrail.case('C5902870')

For parametrized ONE argument: @pytest.mark.parametrize('param', (pytest.param('value1', marks=pytest.mark.testrail(ids='C5902871')), pytest.param('value2', marks=pytest.mark.testrail(ids='C5902872'))))

But i have problem with two or more parametrized arguments: @pytest.mark.parametrize('param1', ('ascend', 'descend')) @pytest.mark.parametrize('param2', ('id', 'hash')) def test_sort(param1, param2): pass

How to link generated tests with testcases id?

allankp commented 5 years ago

This isn't possible with the current implementation, if you would like ti give it a go. Please open a PR

MarkJB commented 5 years ago

I think I might have hit a similar problem (though I'm not stacking parametrize marks, so could be different) and found a work around. In my case, making the testrail ids='string' a tuple works for me

i.e.

pytest.param('a', 'b', id='test case name', marks=[pytest.mark.testrail(ids=('C1234',))])

The problem (in my case) appears to be in plugin.clean_test_ids()

allankp commented 5 years ago

@MarkJB think the issue there is that the ids are not being found: https://github.com/allankp/pytest-testrail/blob/master/pytest_testrail/plugin.py#L112

maksim-andr commented 5 years ago

@MarkJB Thank you for your solution

shivam-bm-ai commented 2 years ago

allankp - I am also facing same issue as TomskDiver. I have already implemented "pytest.mark.paramterize()" but now as I am trying to connect the same with Test rail.

So, I have 1 test function for which there are 10 test case and hence I have parametrised the test function. Now for each case, I want to pass different test case id same as in test rail. Please suggest the solution.

rdubbudu commented 2 years ago

@allankp - I am also having same problem. I would like to include testrail id as part of the parameter so i can map to different test cases from one single function with different parameters.