For the longest time, I thought generating XML reports from Pytest was just… annoying.
- Run tests with -n for parallel workers → I’d get 4 different XML files or more with increasing number of tests.
- Retry a flaky test → extra XMLs scattered around.
- Then I’d have to either write my own merge script or dig up some plugin to stitch them back together.(Not to mention the xml paths relative and absolute and file not found stuff or generating the blobs)
- Finally, I’d spend time debugging why my CI job wasn’t uploading the “right” XML to TestRail.
All of this felt like extra work just to give my test management tool a single file and devops guys who are already loaded and this would be a P3 for them to look at.
While searching for something that would automatically generate and merge, I stumbled upon this underrated tool called pytest-html-plus
, and I was surprised that it quietly solved this problem for me.
All I had to do was:
pytest --generate-xml --xml-report=testrail.xml
And it gave me one combined XML, even with parallel runs and retries. No extra merge step, no custom code.
The XML already included logs, stdout/stderr, flaky test information, screenshots etc. Uploading to my test management tool was finally a single step instead of three, supposedly made my sync with devops team much lesser as they only needed to use the test rail command to upload the xml.
If you are using pytest and trying to link your tests with an test management tool, try this before going for other CI plugins
https://github.com/reporterplus/pytest-html-plus
Phew!
Top comments (0)