Jan 20, 2015

Testing lesson of the day

software, testing

We’re on the tail end of my current engagement and a lot of our tasks are change requests or enhancements as the users are getting more and more time with the software. We have a fairly large integration test suite that we wrote using an inhouse custom Fit extension.

We all know reuse is great - I have some more thoughts in that but another time perhaps. A lot of the test use the same fixtures to get the system to a point where it needs to be for the test at hand to be relevant. This works great because it’s reasonably painless to set up fairly complex scenarios, bootstrap the system and then test what it is you need to test.

Unfortunately this results in some asserts being called when they are really not relevant and they don’t add anything to the current scenario. When the fixtures change due to a user request we all of the sudden find ourselves with a lot of unrelated broken tests. This makes maintenance difficult and adds a lot of drag to our workflow.

The moral of this story is simple: if you’re going to reuse fixtures make sure you don’t assert out of context. It will make your tests brittle and difficult to maintain.