Reactive forms are fun in angular, and fun here means “not fun”.
They’re ‘fun’ because they’re meant to be testable; and easier to reason about, and they are… so long as you don’t do anything advanced, like form controls interacting with each other; or FormArrays, or anything like that.
Or, if you aren’t into Angular; have you ever tried to test an ASP.NET MVC (not .NET Core) controller?
There’s about 12 lines of mocking you have to do to unit test it; and it is a nightmare.
There are those that try to force testing into those situations; as if it’s a good idea to poke yourself in the eye.
Software is built by humans; and sometimes those humans didn’t try a ‘test first’ approach to their code. Trying to isolate and test in these situations means taking on a lot of brittleness by using Mocks and Stubs; and is that really the best use of our time?
There are times that if it hurts you should ‘do it until it doesn’t hurt’, but this isn’t one of those times. If you don’t have control over a library or framework and you find yourself encountering lots of pain trying to write tests for something that interacts with that library, maybe the best answer is… don’t.
One thought on “Some things aren’t built to be tested”