pytest-dev / pytest-dev/pytest
Allow junit_suite_name to be set on any grouping of tests and in a nested manner
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
What's the problem this feature will solve?
Currently it's only possible to set the name of the root suite when running tests, but other frameworks such as jest will create nested test suite elements using the labels provided in the test files. I'm using a JUnit merging tool to assemble several test reports into one file and it uses the test suite names to do so, all my tests from the JavaScript portion of the project using jest are neatly sorted into groups but all my pytest results get lumped into a single suite, I can mitigate this slightly with the junit_suite_name option in the CLI but it only applies to the root element and doesn't support nesting.
Describe the solution you'd like
I think a function you can call anywhere in the file structure that sets a suite name would work here. For example if you call it in the __init__.py of a module, that whole module will be under that suite name, you could also call it in a file, class or individual test. If there were a call at the module level and another at the file level, this would create a file suite nested inside the module suite.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing CLI junit_suite_name option and how pytest emits the root JUnit suite. Review the proposed call sites in init.py, modules, files, classes, and individual tests. Done means suite names can be assigned at those levels and compose into nested JUnit suites for merged reports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100