Sunday, October 16, 2005

Eclipse Update 3.1.1

Usually I am pretty current with all the Eclipse development. If a new milestone build come out, I am there to download it and install it. Since 3.1 I got a bit behind. 3.1 works so nice for me right now and seems to cover all my wishes, that I totally ignored milestone builds for Eclipse 3.2. If I say ignore, that is not true. I just was not aware that there are already two milestone builds for the next version. Today I discovered it. I also noticed that there is an update from Eclipse 3.1 to 3.1.1. This update can be done using the Update Manager.

More information can be found at: http://www.eclipse.org/eclipse/platform-releng/updatesfor3.1.1.html.

Test Coverage with Coverlipse

I am usually creating software project reports with some of the tools coming with Maven and which are very nicely integrated into the project web sites that Maven can produce.

Yesterday I came across a similar tools that comes as Eclipse plugin: Coverclipse.

I installed Coverclipse on my eclipse 3.1 version at home, which I usually do first before I decide to use it at work. The plug-in can be installed with the Eclipse Software Update manager.

A first run on a rather small project seemed to end in an endless loop. I might be wrong but I had the feeling that something was wrong and tried to terminate it, but could not succeed. After restarting Eclipse I was more cautious and explicitly named the package I wanted to include and switched anything else to be excluded from the coverage test. It might be that Coverlispe just wanted to cover everything that is somehow referenced it the project. After setting the filters Coverlipse executed all my JUnit tests in a timely manner. After Coverlipse executs your JUnit tests, it marks in the Eclipse editor on the left bar all lines which are covered with a green check mark and all lines which are uncovered with a red exclamation point. This is very helpfull but one can look at this at a bit dominante. Luckily the Coverlipse Class View has a button that allows to clear all results which also makes the markers on the editor bar vanishing.

I usually do not write unit tests for getters and setters. Coverlispe marks those methods red, which means they are not covered by unit tests. While this is true and undeniable, I wish there would be some filter mechanism similar to the package in- and exclusion that allows to exclude getters and setters from the coverage reports.

All in all I think it is a very nice tool and I will add it to my Eclipse installation at work.

Monday, October 10, 2005

Spring, ApplicationContext, and Testing

I currently struggle with the following problem:

I need to test a SpringFramework Controller class I am using in a web application and need to set the ApplicationContext as used in the web application. My ApplicationContext is set in four or five different application context xml files.

Monday, October 03, 2005

Manage You Bookmarks

While reading an interview with Cedric Beust, the developer of TestNG I came accross a sentence where he was mentioning del.icio.us and tagged bookmarks. Curious as I am I took a look at it, and man this is cool. You can manage all your bookmarks on their server, tag them as often as you wish and then access your bookmarks from any box. This is great! I have bookmarks on my Windows box and bookmarks on my Linux laptop. And then I have a bookmark list on my box at work.

Now I am busy migrating them all to del.icio.us.

Saturday, October 01, 2005

Unit Testing in Java with TestNG

It is now about three years that I started to use JUnit and its family members like DbUnit, XmlUnit etc. For my work I have written a DbUnit wrapper that eases the DbUnit usage. I have used XmlUnit for a while to test XML files. I have also used MockObjects as for example EasyMock, JMock, and others.

Recently I came accross TestNG and started to read about it. Tonight I finally decided to have a close look at TestNG and actually use it. What attracts me first is the grouping of tests and the easy way to include or exclude tests. Eclipse has this nice feature where you can right click on a single test and execute it. I make very often usage of this feature to avoid executing other time intensive tests.

What TestNG provides is so much more advanced. Just group tests with annotations and in your TestNG suite xml file define which ones to include, and which ones to exclude.

Another thing that helps me to get started with TestNG is the fact that there is a TestNG Eclipse plugin which allows to run TestNG test cases in the same way as I am used doing it with JUnit tests.

Maven
TestNG provides also a Maven plugin. It took me a while to figure out how to get it. On the TestNG site I could only locate a page that explains the Maven TestNG plugin, but not how to get it. I finally found the information in the TestNg Group available on Google groups.

What you need to do is the following (copied from the News Group posting):
issue the plugin:download command and answer the questions as follows:
  • artifactId is maven-testng-plugin,
  • groupId is testng,
  • and version is 1.1
You'll need to add http://www.vanwardtechnologies.com/repository to your maven.repo.remote list.