I really like to use static methods (especially for helpers classes). But as static methods are not stubbable, eventually they are a bad practice, aren’t they? So I have to choose between static methods usage convenience and testability. Is there any compromise?
I really like to use static methods (especially for helpers classes). But as static
Share
It depends on what the static methods do.
Is it something that really has to be stubable? Like data access, long running operations etc. or is do you mean helper methods like .ToSlug()?
If it’s the former case, I’d make them instance methods to increase testability / speed of tests.
If it’s the latter, I’d leave them static and just verify their correctness.