A typical TDD(Test Driven Development) is literally a complex way because you need to think all cases prior to development and write the test case; let the test case to fail then do development till your test case passes.

It seems very hard, how can I think of all cases prior to development. In reality, most of the developers don’t know the whole scenario even after completing the development and this is the fact!!!

Have you ever thought, why TDD helps you to develop a great project which will not have any bugs???

What I think is — TDD does not help instead the process helps. But how???

What TDD says is — you write test cases for all your scenarios first so that you should not miss any case while developing it. When we developers write codes, our mind literally fights with his/her own thoughts to find a better logic to solve the problem, meanwhile, we miss some edge cases because this is how our mind works. There is a limit of your mind to think in multiple directions at the same time because you can not focus on multiple things at the same time. And this problem is not enough to use TDD.

Have you ever noticed, when you code, you mostly think from the tech point not from the business point? If you managed to cover all business scenarios still, you will fail to cover all tech scenarios such as empty response, all https status, empty data from DB… there are many scenarios where you might fail to cover while writing code because your mind will become biased towards your code and will restrict your mind to think beyond of the boundary.

So how can you make sure that you are not missing any case???

To do that you need to come out of your developing zone, then you can start fresh thinking. So you need to give some time to think about cases after completing one round of development then think of other or remaining cases and go back to development mode again and keep doing it till you are satisfied that now there won’t be any missing cases.

Don’t you think it’s a time-consuming process?

What if I think of all cases first then I start developing my code? Or Maybe after completing the development, I will start writing test cases. Both situations look good to me but don’t ever do both together.

I find TAD(Test after development) a little less productive and fruitful because you will not get any motivation to write test cases after completing the development because the main purpose is solved because the test engineer has completed testing and it working all fine!

There are some chances that some cases are missed by you as well as the test engineers, which might cause to business disaster. I am not saying that TDD is 100% reliable but it has proven to be most fruitful and successful so far.

So my suggestion would be, before developing anything you should take the proper time to think of all cases and either note them down or write unit test cases for it.

I am going to write a bunch of blogs on how can you use TDD with spring boot in the upcoming weeks. Stay Tuned.

Thanks for your time. Enjoy learning!