-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
Add support for detecting unused setups #747
Comments
If you get your mocks from a mockRepository.VerifyAll();
.NET does not have deterministic resource cleanup like that (we'd need something like C++'s RAII idiom) so that is impossible to do. The closest thing in .NET is the In all honesty, if your tests get so large that you no longer know what mocks and setups you have, then that is the problem to solve; putting a bandaid on it (in the form of a library feature) is not a good way to deal with this (IMO). Refactor your test code, instead. That being said, this problem might be tackled with a Roslyn analyzer. |
@dfev77, any thoughts about the above reply? Otherwise I'll close this issue in a couple of days, since there's not much that can be done (short of rigging setups with a |
Closing due to a lack of feedback (and lack of implementation options). If you'd like to further discuss this or make additional suggestions, feel free to post here -- we can always reopen the issue. |
After a while there is a big chance (especially when dealing with legacy code) to have tons of mock setups that are actually not used.
It would be nice to be able to spot such case in order to cleanup the code.
An option would be to allow the test(s) to fail if there were any mocks which had setups that were not called (at the point where the mock gets out of scope)
The text was updated successfully, but these errors were encountered: