|
|
|
|
|
by rverghes
4202 days ago
|
|
He's assuming that the static method has a dependency on something. That it's not purely functional. For example, public static doSomething() {
Database.write("Did something")
}
Makes testing hard because Database is hardcoded. |
|
In short: static methods are easy to test, methods using static methods (whether static or not) are more difficult to test.
My takeaway: the bar for moving functionality into non-static methods (which will still be decently easy to test) is quite low. If you call a static method, be prepared to own all its functionality when testing the calling method. Taken to logical conclusion, public static methods should be quite small.