0

I have to custom @pytest.mark decorator to build xray reports (and push it ...) With the new parametrized tests xray feature, and associated steps, I would like to get every kw called during iteration (marked as a step) hooks documentation is not so clean to me and i don't find how to do this... does anyone have an idea ?

pytest : 6.2.4

Edit :

test example

import pytest

class Test(object):
    @pytest.mark.xray(test_key='DEMO-1')
    @pytest.mark.parametrize('param1, param2', [(2, 2), (3, 4), (5, 5), (5, 5), (6, "a"), ("aa", "aa")])
    def test_pytest_parametrized_feature_d(self, param1, param2):
        self.kw_one(param1, param2)
        self.kw_three(param1, param2)
        assert param1 == param2

    def kw_one(self, param1, param2):
        self.kw_two(param1, param2)

    def kw_two(self, param1, param2):
        print(param1)
        print(param2)

    def kw_three(self, param1, param2):
        assert param1 == param2

Expected result : steps : kw_one : PASSED kw_two : PASSED kw_three : FAILED

I expect informations in pytest hooks, like : def pytest_terminal_summary(terminalreporter, exitstatus, config):

General Grievance
  • 4,555
  • 31
  • 31
  • 45
yves
  • 1
  • 1
  • Can you please share a simple example of the code you have? Btw, what do you mean exactly with "I would like to get every kw called"? – Sérgio Aug 17 '21 at 08:41
  • Sure ! I have added example in original post – yves Aug 17 '21 at 09:51
  • thanks. what would be relation, if any, between the "kw_*" methods and the Test in Xray? would they relate to the manual steps? If so, then I see there a challenge of how to map kw_something to some *specific* step in Xray, as those steps don't have ids.. they just have an implicit index – Sérgio Aug 17 '21 at 10:17
  • Thanks for your answer. not really ... the aim of the feature is to add steps dynamically (even if not defined manually). Xray allow this since last release, with "pytest with steps" test cases. – yves Aug 17 '21 at 11:02
  • I'd love to pair with you to explore this further. I did some experiments with pytest but I also don't know enough yet about these more advanced use cases – Sérgio Aug 17 '21 at 16:03
  • thanks @Sérgio . See you in the further then ! – yves Aug 18 '21 at 09:23

0 Answers0