Great point Ross! It’s easy to get yourself into trouble although I would argue they’re not difficult to test if you’re careful about their implementation. Too often you end up (as I did in my example) having a hard coded dependency on that static in your method which prevents it from being mocked.
One solution is to pass your static into the methods that rely upon it as a parameter, making it mockable and solving a common unit testing trip-up.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great point Ross! It’s easy to get yourself into trouble although I would argue they’re not difficult to test if you’re careful about their implementation. Too often you end up (as I did in my example) having a hard coded dependency on that static in your method which prevents it from being mocked.
One solution is to pass your static into the methods that rely upon it as a parameter, making it mockable and solving a common unit testing trip-up.