-
Notifications
You must be signed in to change notification settings - Fork 163
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
Mocking a class with @Deprecated methods should include the same Deprecation warnings #677
Comments
I agree, I think there are a few annotations for which it is idiomatic for subclasses to be similarly annotated: |
Seems quite doable, but I likely won't have time to implement this anytime soon. And we probably want to start looking at macros, instead of investing more time into improving the codegen. |
I don't understand the value here. When I invoke a method on a What are the use cases for removing calls to deprecated APIs on |
If I mark a method as But if I've mocked it, that's false. If I delete the deprecated code, then when I run build runner my tests are littered with errors, without the hints on how to fix it that I wrote in all those When you're doing something huge, like deprecating and replacing an entire database, having the deprecation notices in the mocks would save a massive amount of time. |
It sounds like the information you're directly interested in is which methods are stubbed but not called. A deprecated mock is a good proxy in the specific case where If we can solve the deprecation forwarding we may as well do it to catch this subset where it's easy. I do wonder if folks would be interested in being strict about only stubbing calls that do get made to help catch dead stubs. |
+1 I think this is a real cause of bloat and dead code that slowly grows in tests with mocks. I've never come up with a good solution for "at the end of a test case / all test cases, check which stubs were unnecessary." Other than a mutations testing framework, which are typically very expensive and would not be a built-in check. |
When a class with fields or methods marked as
@Deprecated("someMessage")
are Mocked, the@Deprecated
is stripped away from the resulting Mock class.It's very helpful for Dart Analysis to point out deprecated code with warnings, but with Mocked classes, the warnings all disappear - methods that are or aren't deprecated are indistinguishable from each other. Updating tests becomes quite the chore.
It would be helpful to include a way to toggle including / excluding
@Deprecated
annotations when generating Mocks, though to prevent a breaking change, I suspect it would have to be set to false by default.The text was updated successfully, but these errors were encountered: