I have a sealed class with protected methods whose behaviour I want to test. This makes it hard to test directly, and hard to mock.
It's in a codebase that wasn't developed in a TDD manner, and I'm now adding unit tests for specific functionality.
What are the general approaches possible in this case? At the moment I have:
Are there any more?
A protected method in a sealed class is effectively the same as private (I guess if you seal a derived class where the base class has a protected member these can come up naturally.)
And there's no point testing private methods. Because they have no public behavior except that which is accessible through the public methods of the defining class, their behavior should be tested by testing the public methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With