Hi Reed, You should take a look at parametrizing[1] so you end up with only:
/api_test test_device_api01.py test_device_api02.py test_device_api03.py And inside it all tests are parametrized based on LAN_URL and WAN_URL (possibly using a parametrized fixture if it is more convenient). Report generation will remain unaffected. Hope this helps, Bruno. [1] https://docs.pytest.org/en/latest/parametrize.html On Fri, May 11, 2018 at 12:38 AM Reed Xia <huaqin2...@gmail.com> wrote: > Hi, > > In my project there are some API tests(with pytest) like following: > > /api_test > test_device_api01_via_lan.py > test_device_api02_via_lan.py > test_device_api03_via_lan.py > > test_device_api01_via_wan.py > test_device_api02_via_wan.py > test_device_api03_via_wan.py > > As you see and you may guess, yes...the two set of test_*.py have the > almost the same code, except they use the different global variable, one is > LAN_URL the other is WAN_URL, looks stupid, right? :( > > So I want to refactor it, I think the two set of tests should not be > seperated just because of an variable. > > but there's another problem, this test project run with Jenkins, launched > by "python3 -m py.test --junitxml=./result/api_test_result.xml",so that > Jenkins can collect the JUnit formate xml file. > > I think I easily to launch the tests in loop by giving LAN_URL and > WAN_URL, but I didn't figure out how to generate a JUnit XML file in this > way, can someone please share some ideas? > > Thanks, > Reed > > > _______________________________________________ > pytest-dev mailing list > pytest-dev@python.org > https://mail.python.org/mailman/listinfo/pytest-dev >
_______________________________________________ pytest-dev mailing list pytest-dev@python.org https://mail.python.org/mailman/listinfo/pytest-dev