Monday, August 15, 2011

Should You Unit Test Interaction with Static Methods?

No. You should not. Here's an example:

If you are somehow mocking this static method, you are potentially making it dangerous for other places where this static method is used. Eventually, this will create red test results that are hard to find and make your tests dependent on each other.