Skip to content
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

Remove final keyword from first party reporters #2887

Open
bearbones opened this issue Jul 11, 2024 · 3 comments
Open

Remove final keyword from first party reporters #2887

bearbones opened this issue Jul 11, 2024 · 3 comments
Labels

Comments

@bearbones
Copy link

Description
I don't know why the first party reporters are "not intended to be inherited from," but for my use case, all I want is a ConsoleReporter that doesn't print the test spec filter at the start of each run. To me, the most reasonable option is to inherit from ConsoleReporter and override noMatchingTestCases() and testRunStarting(), but I can't do that when it's final.

I could just edit ConsoleReporter in our fork, but I would prefer to not have to keep a version that's slightly out of sync with the base repo.

Additional context
My team's custom main() generates a ridiculously long filter based on a file that lists excluded tests. This is to accommodate legacy tests that were written with Boost.Test macros. We redefined those macros to map to Catch2 along with some extra legwork for keeping track of suites and constructing case names. Right now it floods the console with about 90k characters.

I also need to print out a special message for our meta-test-runner to recognize at the start and end of runs and cases, and I could do that with an event listener, but it seems more elegant to just override those few ConsoleReporter functions.

@horenmar
Copy link
Member

horenmar commented Jul 19, 2024

You will end up with your own reporter either way, and I would rather have you copy paste ConsoleReporter into CompanyConsoleReporterDoNotSteal, than derive CompanyConsoleReporterDoNotSteal from the built in one.

The underlying reason is simple, I do not want to have to consider whether a refactoring to reporters changes their behaviour if some of the functions are overridden and some are not. As an example, right now the ConsoleReporter only responds to testCaseEnded event, and ignores partial test cases. If I decide to change this in the future, so that it uses the newer testCasePartialEnded (and testCasePartialStarting for resets) for more granular control over the output, I do not want to have to think about whether the users have overridden these already, whether they call the parent's implementation for them, etc.

@horenmar
Copy link
Member

Also I am told that I should ask you if you work at Roblox 😃

@horenmar horenmar added the Query label Jul 31, 2024
@bearbones
Copy link
Author

Okay, that makes sense.

And to your question, yeah 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants