8

Some things aren’t built to be tested

 3 years ago
source link: https://georgestocker.com/2021/02/01/some-things-arent-built-to-be-tested/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Some things aren’t built to be tested

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.

Get Daily Tips on building better software, faster with Test Driven Development

Subscribe to get daily emails that will help your team build better software, faster.

We won't send you spam. Unsubscribe at any time.

9ed3482ccbb461fbf8796b251caf8f4d?s=49&d=identicon&r=gAuthor geostockPosted on February 1, 2021Categories Uncategorized


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK