Many developers still not seem to the the value and need for unit tests.

What might be are the reasons for this so we can address it?


Give them training in writing good unit-tests and show them how they help with refactoring. Most developers I know love refactoring, writing tests soso, but they love refactoring with confidence more.

Also good tests lower debugging time, which is also something developers dislike. The Google internal Testings on the Toilet movement focuses on this with their moto: Debugging sucks, Testing rocks.


Write Unit tests!
Observe the testing quadrants!!
Follow the test pyramid!!!

Many companies state these objectives but fail to follow though on making sure that the actual issues encountered writing unit tests are recognized and addressed. That's a lot more organizational support needed. If it is enforced with deadlines and number of tests metrics it may not end well. The recent desire for KPIs and metrics everywhere can be dangerous if used bluntly here. Remember, past a certain point, more tests is WORSE not better because they will fail incorrectly and take maintenance.

I would consider starting with the following survey to unearth what the issue(s) are:

What gets in your way of writing unit tests while you work?

I would use multi-choice answers of

  • I don’t know where to start
  • I don’t have enough time generally
  • The environment or database is unstable causing them to fail and not provide value
  • When I am given a fixed deadline, sometimes there isn’t enough time for testing
  • Production is broken and we don’t have time for unit tests right now
  • I don’t have exiting templates to base new code on
  • I don’t know patterns and practices for writing unit tests
  • I haven’t written unit tests before
  • I don’t know how to do the mock and stub piece
  • I don’t know when to use them and when not to
  • I don’t understand how to make them part of a suite that others will run
  • I don’t understand how to create and run certain tests when a real user id is needed

That is just a start. It is just an assessment of the current practices.
However it will give you a good start on knowing where to work on improving quality and lets face it that is the first step in any such process - get the raw data so you know where the issues (are). Otherwise you might work on fixing the wrong thing and not fixing the right thing!

In order to actually improve quality you will need to find ways to promote each of these items. Some initial suggestions are:

  • Improve developers ability to state their need for time to work on tests. Constantly encourage assertiveness and mistakes
  • Allocate time (weeks and months) to work on the environment. Not just 'Wednesday for a couple of hours'. Make sure that this time is included in any sort of estimates for the business.
  • Educate management that fixed deadlines hinder quality. Work with them to find a way to limit scope instead of quality
  • Do not make unit tests optional and nice to have if we have time. Make them as much a part of the development as the application code. This takes discipline.
  • Ensure that all external dependencies (services, database, network, file system, etc.) use stubs and mocks. Do not make the use of mocking and stubbing in unit tests optional and a 'nice to have if we have time'. Make them as much a part of the development as the application code. This takes discipline.
  • Provide education, training, Lunch and learns and other forums to encourage learning about Agile testing
  • Solve 'user id' problems up front instead of hiding a hack
  • Also even on the face of it "do a survey" is a low quality answer. – jonrsharpe Mar 3 at 18:09
  • I might suggest the term 'incomplete'. But point taken. answer ended in the (first) bullet list above but that is just the start. Let me add to the answer now with a second bullet list of actions to consider taking. Assessing the current landscape is a valuable approach in my experience. It's a listen first approach. It helps to avoid fixing the wrong thing and ensure fixing the right thing. – Michael Durrant Mar 4 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.