Recently I had to adapt some older Java code to support a new requirement: an existing CSV report needed to include a user’s email address, translated from the user id. Pretty simple, but how does the CSV report generator translate the user id to an email address?
Continue reading Picking the right abstraction
While implementing a simple event store for an example application I needed to serialize JSON data to binary arrays and turn those bytes back into the original JSON. Obviously, that’s a piece of cake!
Continue reading Serializing strings, Unicode, and randomized testing using ScalaCheck
One of the principles of a good unit test is that they are repeatable. This is especially important if the tests involve dates. Typically this is programmed in the setUp and tearDown of the unit tests. This might lead to duplication if multiple tests depend on such a fixed date. Of course we can abstract this to an Abstract base class, but in the end we all know that reuse via inheritance is a bad idea. JUnit @Rule can be a solution for this.
Continue reading Fixing date in test using JUnit MethodRule
As a good pragmatic programmer you should learn at least one new language per year. For me this year’s (2011) language will be Ruby (I know I am a bit late…). A Kata is an excellent and fun way to learn a new progamming language as well as your (new) IDE or text editor. As Kata I chose the Bowling Game Kata from Uncle Bob. Read on if you want to see how my Bowling Game looks like in Ruby.
Continue reading Bowling Game Kata in Ruby
A short while back I started to work with Ruby on Rails. Incredible fun and inspiring. One of the (many) things I like is the distinction Rails creates of the different levels of test scopes. It has separate folders to store unit, functional, integration and performance tests.
Now in Java – and using the Maven default folder layout – you get one folder for storing your production code (
src/main/java) and one for your test code (
src/test/java). That got me to thinking to apply Rails’ way to structure your Java test suite. After a while it can be tricky to organize to test code, so I wanted to give it a shot with Java.
Continue reading Organizing test code in Java