Top Unit Test Tools

1 02 2010

One of the main benefits of the Agile methodologies (XP, Scrum, etc) is the growing popularity of unit testing. This used to be a dark art practiced by the most geeky of geeks. Only a very brave developer would spend time implementing a unit test instead of rushing a shiny new feature out the door. However, software developers (and their managers) have seen the light (or are, at least,  a little more open to trying out this practice on real projects).

I have been “unit testing” for the last 8 years. Recently I decided to give my unit testing toolkit an update and check out what new shiny toys are available. Here is a summary of what I found / experimented with…

  • Jmockit. This is the best mocking framework I can find. It is magical. With JDK 1.6, you add the jar to the class-path and you can instatnly mock anything. Yes, anything. I tried mocking static methods, final methods, private methods, objects created with the new operator. There is nothing this baby can not do!! Check out the comparison matrix.
  • Jmockit code coverage. Not only can this tool mock with the best of them, it can do code coverage as well. Seeing the tested paths really helps you in building efficient and comprehensive tests. It even tracks how many of the possible execution paths are covered. Put that in your pipe and smoke it!!
  • DBunit. This old tool has been brought back to life by a new team of developer. It is the best way to set-up a database before running your test. Mocks can get you a long way, but sometimes you just need to test with a real (big) database!!
  • Fest assert. OK, so I am a sucker for cool open source jars. This library makes your asserts much more readable.
  • TestNG. While JUnit 3.8 stagnated the Java unit testing world, TestNG rocketed ahead with features like annotations, parametrized tests, threaded tests, etc. JUnit 4 closed the gap a little, but TestNG is still ahead. Take it out for a spin and ditch that JUnit clunker.
  • Selenium. I am just getting my head around this tool. So far it seems the best way to test web sites. I have tried many other “web testing tools” and they all suck eggs big time. This one seems to have legs, but make sure you ditch the x-path locators (use css ones instead) and html format (use TestNG instead)

With so many great tools, there is no excuse for not developing (and maintaining) a comprehensive set of unit tests for your project!!

Advertisements

Actions

Information

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s




%d bloggers like this: