Monday, April 9, 2018

More Integration Tests, Less Mocking, More Linting

Read this great article today by Kent C Dodds


My take away from it is the following:

1. Integration Tests give the best ROI - but people start to write unmaintnable monoliths by getting obsessed with too much code coverage and trying to mock absolutely everything.  On the other hand too much end to end testing results in fragile tests that become up a maintenance issue (see software testing ice cream cone anti-patten).  A focus on integration testing gives the best bang for buck.  

2.  Linting is good - There are lots of good linting tools out there.  You can usually hook them up in with your IDE so they can give you feedback every time you compile.  These will help improve the quality of your code and may help pick up simple bugs that people rely on 100% unit test coverage to eliminate. 

I couldn't agree with this article more.  Especially point 1.  This isn't to say that we don't need some decent unit test coverage.  But lets not get obsessed with 100% or you will find yourself spending so much time writing and maintaining tests that you lose your agility which is the whole thing TDD is supposed to support. 

Thursday, February 22, 2018

Dependency Injection

In my day job I've been helping architect a restful service framework for another group.  Amazingly the  developers in this group weren't aware of dependency injection.  After confusing them by trying to explain the concept and how mocking works etc I decided to hunt around for a simple example.  I was surprised at how bad most of the explanations and examples out there are.  Fortunately I stumbled across this excellent blog post on CodeArsenal.net.


I showed it to the developers and they said it instantly clicked.