A Pragmatic Approach to Continuous Delivery

Summer time means less people at work and more time to think ahead what to do the remaining part of the year. In my case it means that I have signed up for a talk called A Pragmatic Approach to Continuous Delivery at jDays, a Swedish Java Developer Conference located in Gothenburg. Read the abstract here, and vote for it here if you think it sounds interesting.

While I was at it, I also proposed a lightening talk on the same subject to Smidig 2012, a Norwegian Agile Developer Conference in Oslo.

Candidate for Daily WTF

To cry…or laugh…that’s the question…

@Test
public void spaceFiller() {
   int l = 5;
   String result = MessageUtil.spaceFiller(5);
   if (result.length() == l) {
   } else {
      fail();
   }
}

When I came across the test code above I wondered who on Earth would write such a thing. The answer came shortly after when I had a look at the method it is testing…

/**
 * Space filler.
 * Creates a string filled with spaces of the wanted length
 *
 * @param length the length of the wanted string
 * @return the string
 */
public static String spaceFiller(int length){
   String s = "";
   for(int i=0; i < length; i++)
      s = s.concat(" ");
   return s;
}

The good thing is that they actually wrote a nice and clear JavaDoc explaining their own stupidity…

Are Unit Tests Necessary?

At work today I came across a project that had not written a single unit test for their new code and wondered what the hell they were doing. Nothing unusual except that apart from the usual excuses about time constraint etc., they had the guts to challenge the value of unit tests. I did not believe what I heard and for a moment wondered if I had gone through some kind of time capsule when I was visiting the pyramids in Cairo last week and come back in a time before unit testing was invented. But a quick glance at the date on my watch ensured me that it was still 2010.

The only comforting thing about this is that as long as there are projects like this, there will be plenty of work for software consultants to clean up the mess. Just a pity that the first couple of weeks will be spent writing unit tests to be able to start refactoring the code. Good thing that writing unit tests are pretty fun and addicting, or to quote one of Kent Beck’s tweet earlier today “… tests are like potato chips”.

JUnitMax

Kent Beck has released JUnitMax.

“JUnit Max is an Eclipse plug-in that helps programmers stay focused on coding by running tests intelligently and reporting results unobtrusively. Every time you save a Java file, Max will run your tests and report errors like compile errors. In addition, Max runs the tests most likely to fail first, so you only have to pay close attention to test results for a second (literally) before getting back to coding, even if you have a long-running test suite.”

Running tests in the background is nothing new. A continuous testing plugin for Eclipse has existed for a while. What is new here is the logic deciding in which order the tests should run. But I am not sure people are willing to pay $2/month for it. There are too many free tools out there… I will be waiting for the NetBeans plugin before i give it a try anyway…

JUnitFactory

Agitar has launched a plug-in to Eclipse for test generation. The way it works is that your code is sent to their server where tests are generated and returned to you. The tests are generated by the same technology that is used in AgitarOne. Since it is experimental, it can even contain features that are not available in the commercial Agitar products yet.

I have just tested JUnit Factory on simple classes but it seems excellent! The test code looks fine, all your tests are listed with status information. You even get a coverage report and coverage markers in your code.

The only catch I have found so far is that you have to be online to be able to generate new tests. I found that out when I tried to test the plug-in while I was working offline on the train yesterday…

More information and request for download can be found on http://www.junitfactory.com/

AgitarOne

Writing tests for existing code is time consuming and boring for the developers and thus often neglected. Agitar recently launched a new tool called AgitarOne. This tool generates JUnit tests for your existing legacy application to make sure you do not break anything when you start adding functionality or refactoring the code base. Hopefully it will not be priced to high…

More information about AgitarOne can be found here.