Showing posts with label Unit Testing. Show all posts
Showing posts with label Unit Testing. Show all posts

Sunday, 30 July 2017

Unit testing your POJO classes in Java.

Ever bothered about testing your pojo classes in java. Probably NO. We tend to ignore these pojo classes saying why should I test lame methods i.e. setter, getters, toString etc.

However these pojo classes adds to your test coverage report and if you don't have tests written for these classes you'll end up with a reduced test coverage stats for your java project.

What about delegating the testing responsibility to a framework or library which will ensure the quality of your pojo classes. Cool Huh !!!

I have got such a situation in my project and found this cool library POJO-TESTER to serve the purpose.

What about giving it a quick look around? Happy Testing !!!!




Sunday, 9 November 2014

Strengthen your test suite - Mutation Testing

Hey Guys, I found this interesting thing sometime back and was wondering how can somebody be not using this.

So we must be encountered the following situations while Unit Testing our code:
  • Hey there are some more scenarios against which we have to test the method !!!
  • Hey I did not take this scenario into account while unit testing and this results in a production issue.
  • Hey I had 100% code coverage, how can a bug will come?
Myth here is : 100% Code Coverage does not mean 100% Test Scenarios are covered.

The answer to all the above or to avoid such conditions is to use Mutation Testing. A cool testing technique to validate and enhance your test suite.
There are several Mutation Testing frameworks present right now however the most simple and active framework named PIT is a good choice.

Following are some other framework for Mutation Testing:
  • Jester Source-based mutation testing tool for Java
  • Judy Mutation testing tool for Java
  • Jumble Bytecode-based mutation testing tool for Java

Links to go through: