domingo, 15 de mayo de 2011

Autotest: friend or foe

For all of you who don't know what autotest is, it's just a ruby gem that lets you run your tests automatically in the background every time you make a change either in your code or in your tests. It is very clever, and a lot of people use it. You can see some examples in almost every screencast of a kata written in ruby.

Why I don't like autotest
Well, it's not that I don't like it. It is a very cool project and I've used it sometimes while performing a kata. My real problem with it is that it breaks the TDD cycle. Let me explain myself.

Running the test should be a blocking step
When we are doing TDD, we run the tests to get feedback. Then, we use that feedback to guide our code/design.
When we use autotest we are not waiting for the tests to fail, we just continue coding, ruining the TDD cycle.

Wait a second, I do not write any code till autotest tells me that there is a failing test.
Well done. Why are you using autotest then?

Update: Talking with Tom Brand the other day, he said that maybe it is ok to use autotest in the refactoring phase. I think he is right :)

3 comentarios:

  1. I wonder if it's just that this kind of use you describe of autotest is simply a wrong use.

    Autotest for me is just something that saves me the hassle of changing context and executing some commands in the shell.

    When I work with auotest I open an allways-on-top window to the left of my IDE and I let autotest run forever. Then, when I make some changes to my tests I get the results inmediately, read the error message and work for the green light.

    Even more, working with autotest is great to train yourself to do the smallest change and then save it, not to save at every line written. This way, you focus on solving the task ahead in the smallest ammount of steps possible.

    ResponderEliminar
  2. Maybe you are right :) That's why I wrote this post, to see how people use autotest. Thank you!

    ResponderEliminar
  3. You're welcome!

    I'm happy to share my experience (possitive so far) with autotest as I've developed myself one in shell-script for PHPUnit and it's been a great improvement in my day-to-day workflow when test-driving.

    Also, It'll be great to hear from other users about good/bad practices to learn more.

    ResponderEliminar