Trust your tests!
If you are not writing any tests today, your development process probably looks something like this:
- Write some code.
- Open browser to verify.
- Write some more code.
- Open browser to verify.
- Write some more code.
- Open browser to verify.
- Write some more code.
- Open browser to verify.
- Write some more code.
- .. 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:
- Write some code.
- + Write some tests.
- Open browser to verify.
- Write some more code.
- + Write some more tests.
- Open browser to verify.
- Write some more code.
- + Write some more tests.
- Open browser to verify.
- Write some more code.
- + Write some more tests.
- Open browser to verify.
- Write some more code.
- + Write some more tests.
- .. 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:
- Write some code.
- Write some tests.
- Write some more code.
- Write some more tests.
- Write some more code.
- Write some more tests.
- Write some more code.
- Write some more tests.
- Write some more code.
- .. 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! ❤️