Changing the Order of your UnitTests

Friday 2011-04-01

A few months ago we had a problem where Eclipse could not automatically run all jUnit unit tests in a package if that package references a class called “enum”, which is a reserved word in Java 1.6. I’ll spare you the details, but we were forced to create a TestSuite. Normally we avoid this construction because it’s easy to create a new unit test and forget to add it to the correct TestSuit. So as a workaround we wrote some code which could build and return a TestSuite dynamically. Right-click in eclipse, select “Run as Unittest”, sit back and enjoy.

Lately this piece of code came in handy while testing another application, which required the removal of data from a database. Yes I know, Unittests should maybe not depend on databases because it leans towards integration testing, but here we are, and I need to solve it. I used the old TestSuite code and changed it so that the TestCase I needed to run first was singled out, while still maintaining the functionality of auto-detecting testcases in the source folder.

Read the rest of this entry »

Micro Victories

Thursday 2008-12-11

TrophyThe last few weeks I was frustrated about not being able to write any code for the project I am on at work. My days are filled with email, spreadsheets, documents, discussions and distractions. All important stuff, I’m sure, but none of it has got to do with actual coding.

I tried to write code during the evenings for that project, just to get my kicks. Two things happened:

  1. Frustration grew, because I feel that this is the kind of work I should be doing during the day. 
  2. As I worked the late night hours, I realized I could never get it all done because the blocks of work were simply to large and required too much research to be done during a few evenings.

Read the rest of this entry »