Using EclEmma to Write Better Unit Tests

If you don’t already write unit tests you should be. (Hey, why aren’t you writing unit tests?) Unit testing has so many benefits and the upfront developer cost to write some unit tests can pay huge dividends later when you aren’t spending time debugging broken code nor attempting to save face due to clueless mistakes. You can also use them as a contract to the expectations of your implementations.

So, assuming you have some unit tests, how useful are they if they don’t test everything? At some level you will want to have a good idea that you’re testing everything. (NOTE: I mean everything really important. Writing perfect 100% coverage like this would likely be too expensive for the entire codebase.) This is where Emma comes in (and more importantly for us, EclEmma, an Eclipse plugin for Emma). Emma is a code coverage tool which lets you visual which parts of your code get executed during some execution (regular or JUnit).

Lets walk through using EclEmma to ensure that we have adequate testing being done. Lets test the following two classes.
More on Using EclEmma to Write Better Unit Tests

Using Pretty URLs with Spring and Annotations

I’m currently working on a Java Web App with Spring. If you aren’t familiar with the Spring Framework, especially with the annotation support, then you’ve never had the pleasure of developing a web app in Java (but you may have experienced the pain). In another post, I will explain why this is so amazing, but for now lets just assume you know.

If you notice on blogs or other sites they have something called “pretty urls”. Essentially if you had a blog, this lets you have /post/welcome-to-my-site/ instead of /post/?id=33. Using the Spring Framework and the hot new annotation support in 2.5.1, you can easily achieve that.

More on Using Pretty URLs with Spring and Annotations