When Not to Automate
September 13th, 2007 by James CarrEdit: Don’t get me wrong… I still stand by my motto to “Automate All Tests” … my viewpoint here is that sometimes you should use common sense if an automated test provides zero value.
In a previous post, I ranted that we should work to “Automate All Tests.” And I still stand by my original sentiment… as professionals, we should always strive to write as many automated tests as we can to ensure quality. One posted a comment asking “How about when not to automate?” Well, I think this iteration I finally came across the scenario in a project when you shouldn’t automate.
Part of this iteration we had a few cards related to changing the look and feel of a few pages on our site (which all contained forms) and updating some of the static text. We made our changes, uploaded the images, and tested across browsers and made sure everything still worked. Then our QA (who is also a little new) asked, “Shouldn’t we have some automated tests for this card?” I shook my head no. “But shouldn’t we try to automate tests for everything?”
I think this is the case where you shouldn’t… and I’ll explain why. For starters, the UI is always a volatile place that can change frequently.. writing tests around that ensures you’ll have broken tests in the near future. Second, what business logic are you testing? Like I said before, writing a test for static text is silly… there is zero effort in adding that text, writing the test would be more time intensive, and again your test will break next time the customer wants to change it (and FFS, TDD’ing text is really plain out silly). And finally, building off the last reason, the domain is what matters most… that’s why we spend much effort decoupling our view from the model so that we can test our model in isolation.
This is why I tend to really criticize Fitnesse fixtures like HtmlFixture or even Selenium to an extent (I have found a lot of GOOD use for that tool however)… the domain language of these tests tend to be very web developer centric (elements, ids, etc) and as a result largely focus on the UI so much that they completely ignore the domain logic happening behind the scenes. IMHO a test to make sure form fields are present is a waste of time. On the other hand, a test that fills out those form fields with different combinations of data, submits them, and verifies the expected outputs is a VERY worthwhile test.
Remember the key point is to ask yourself what benefit you gain from writing an automated test, and whether that benefit is worthwhile. For me, a simple gander at the UI and asking the customer to confirm it looks good is “good enough” and gives me time to focus on writing tests for and developing the domain layer more.
And the domain layer is the most important place in you application. Period. ![]()