man in white shirt using macbook pro
Photo by Tim Gouw on

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.

Unit Testing

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.

Test Coverage

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.

Final Words

Having no Test Case written is better than writing Wrong Test Case

So be sure what you are testing and how you are testing.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s