Have you ever sent a buggy release to production, then this post might help you next time.
Due to urgent requirement or crunched deadline, sometime we have faced this problem during our career that some functionality or API stops working properly after release.
Well this is occurs usually with developers but we can avoid it and become more confident next time.
I had’t written a single test case till 4 years of my career and I can give various reasons or excuses for that, but at the end I started. If you thinking writing test case is just an overhead, you might don’t know it’s power.
This is type of testing that we as developers have to perform so that all unit functionalities should not break.
You can start with a simple functionality of adding a record into db or performing some arithmetic operation.
Start with failure or negative case and then move to positive ones. Negative cases are those which a developer mostly don’t think. For example.
- If user age is not available, when you are going to save it into db.
- If in some case of update, code should throw exception etc..
So identify those and write a simple test case. They are small but have big impact across project.
If you have written ton’s of test case, but that doesn’t guarantees that you have covered all things. For that we can use test coverage tools. In IntelliJ community version they are available by default. In eclipse you have install plugins.
Test Coverage is about statistics. How %age of line of code you have covered by test cases.
This gives you confidence about your code and project release.
Having no Test Case written is better than writing Wrong Test Case
So be sure what you are testing and how you are testing.