Wednesday, July 07, 2004
Multi-threaded testing with JUnit
A good lesson learned from my run-in with SimpleDateFormat and threads was that JUnit itself does not test threading particularly well. Luckily there are a number of projects out there that add the missing pieces.
I checked out several, including GroboUtills and JUnitPerf. Docs for both were a bit sparse, but I ended up choosing JUnitPerf. The two articles (here and here) showed GroboUtils requiring the use of inner classes, which seemed more of a hassle than JUnitPerf.
Using JUnitPerf, I was able to bang out a good test suite quickly and voila! -- the threading issues with SimpleDateFormat became immediately apparent. As I already had the test cases written, it was easy enough to modify the use of SimpleDateFormat and retest (gotta love refactoring)
I checked out several, including GroboUtills and JUnitPerf. Docs for both were a bit sparse, but I ended up choosing JUnitPerf. The two articles (here and here) showed GroboUtils requiring the use of inner classes, which seemed more of a hassle than JUnitPerf.
Using JUnitPerf, I was able to bang out a good test suite quickly and voila! -- the threading issues with SimpleDateFormat became immediately apparent. As I already had the test cases written, it was easy enough to modify the use of SimpleDateFormat and retest (gotta love refactoring)
