Is static universally "evil" for unit testing and if so why does resharper recommend it?

Posted by Vaccano on Programmers See other posts from Programmers or by Vaccano
Published on 2010-09-21T01:18:36Z Indexed on 2012/11/29 17:18 UTC
Read the original article Hit count: 272

Filed under:
|
|
|
|

I have found that there are only 3 ways to unit test (mock/stub) dependencies that are static in C#.NET:

Given that two of these are not free and one has not hit release 1.0, mocking static stuff is not too easy.

Does that make static methods and such "evil" (in the unit testing sense)? And if so, why does resharper want me to make anything that can be static, static? (Assuming resharper is not also "evil".)

Clarification: I am talking about the scenario when you want to unit test a method and that method calls a static method in a different unit/class. By most definitions of unit testing, if you just let the method under test call the static method in the other unit/class then you are not unit testing, you are integration testing. (Useful, but not a unit test.)

© Programmers or respective owner

Related posts about c#

Related posts about unit-testing