Trust your tests!

If you are not writing any tests today, your development process probably looks something like this:

  1. Write some code.
  2. Open browser to verify. 
  3. Write some more code.
  4. Open browser to verify.
  5. Write some more code.
  6. Open browser to verify.
  7. Write some more code.
  8. Open browser to verify.
  9. Write some more code.
  10. .. workday is over and you get to go home to your family.

Obviously with a bunch of meetings and coffee breaks scattered in there aswell. But then one day you think to yourself:

-"Maybe I should pick up this testing thing that I know I should be doing but never find the time to!?"

And you start adding tests to your development process, which now looks something like this:

  1. Write some code.
  2. + Write some tests.
  3. Open browser to verify.
  4. Write some more code.
  5. + Write some more tests.
  6. Open browser to verify.
  7. Write some more code.
  8. + Write some more tests.
  9. Open browser to verify.
  10. Write some more code.
  11. + Write some more tests.
  12. Open browser to verify.
  13. Write some more code.
  14. + Write some more tests.
  15. .. workday is over and you get to go home to your family.

See what happened here? By adding another step to our development cycle of course our productivity will decrease compared to when we didn't write any tests.

This is probably the reason a lot of developers who are not writing any tests say it's because:

-"I dont have the time to write tests!"

Of course you dont! Not this way. You can't add an extra step to your cycle and then expect to be able to complete the same amount of work as you did before.

I could give you the old argument that testing is a long term investment and you will make up for this lost time in the long run. But that's little comfort today when you feel like the slowest developer on the planet just because you finally decided to start writing tests.

So how do you incorporate testing in your development process without loosing productivity today? The solution is quite simple:

Trust your tests, don't open your browser all the time!

Tests are meant to replace our browser clicking and instead give us instant and reliable feedback if our code is working or not. The browser is just a presentation layer. Trust your tests!

Of course we probably need to open the browser at least once or twice before we merge / deploy our code just to make sure everything looks the way we expected, but if you are a backend developer you should be able to reduce the amount of browser clicking heavily by writing tests. Instead your development process should look something like this:

  1. Write some code.
  2. Write some tests.
  3. Write some more code.
  4. Write some more tests.
  5. Write some more code.
  6. Write some more tests.
  7. Write some more code.
  8. Write some more tests.
  9. Write some more code.
  10. .. open the browser at the end of your workday just to verify that everything looks as expected, then go home to your family and tell them about all the awesome tests you've written today!

Cheers friends! ❤️