Skip to content

Add a unique test counter to the final report #11370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pomponchik opened this issue Aug 30, 2023 · 7 comments
Closed

Add a unique test counter to the final report #11370

pomponchik opened this issue Aug 30, 2023 · 7 comments
Labels
topic: reporting related to terminal output and user-facing messages and errors type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@pomponchik
Copy link
Contributor

What's the problem this feature will solve?

Hello! I'm a big fan of pytest. However, I ran into a problem when using pytest.mark.parametrize.

The fact is that each individual parameter for the test is always displayed as a whole test in the final report. For me, these reports are an important indicator, and it is important for me to distinguish unique tests from tests that are generated by the transmitted parameters.

Describe the solution you'd like

Ideally I would like to see both numbers: how many unique tests and how many of them in total, taking into account parameterized ones. This can be done both by default and when using a special command line option, for example --show_unique_tests_number.

@nicoddemus
Copy link
Member

Hi @pomponchik ,

IMHO this feature is too specific to go into the core, but is something you can cook up yourself via a custom plugin (conftest.py).

One idea is to via pytest_report_teststatus count the "unique" items, and then pytest_terminal_summary to show a message with the unique items.

@RonnyPfannschmidt
Copy link
Member

As far as pytest is concerned,each of the parameter combinations is a unique test item

So from the standpoint of the architecture, you want to count test "definitions"

Currently test definitions are only partially exposed in test Generation but not as Part of the collection tree

The final test items include parameterization

@pomponchik
Copy link
Contributor Author

So from the standpoint of the architecture, you want to count test "definitions"

Yes, that's right, I want to count definitions.

@The-Compiler
Copy link
Member

IMHO this might be an useful enough metric to show by default. It's nice to see that I have a couple thousand tests in my project, but I suspect this is for a big part from a couple of big parametrizations, so this would help to get a better feeling of the state of things (and also clarify things for beginners perhaps, who might be less aware of parametrizations).

@nicoddemus
Copy link
Member

Not sure @The-Compiler, my gut feeling is that this will be confused to beginners specifically. But I don't care much either way TBH, so I'm changing my position here to -0 if somebody cares to implement this.

@pomponchik
Copy link
Contributor Author

pomponchik commented Aug 30, 2023

@nicoddemus I was a beginner some time ago, and it was the current behavior that was a little shock to me.

@Zac-HD Zac-HD added type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature topic: reporting related to terminal output and user-facing messages and errors labels Sep 7, 2023
@Zac-HD
Copy link
Member

Zac-HD commented Jul 6, 2024

Closing this because as per #12465 (comment) it can be implemented in an external plugin.

@Zac-HD Zac-HD closed this as not planned Won't fix, can't repro, duplicate, stale Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: reporting related to terminal output and user-facing messages and errors type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

No branches or pull requests

5 participants