a rest is as good as a test

Wed, Oct 1, 2008

There I was, a full day at the coal face implementing digital signature validation and certificate trusting for the Guanxi SP Engine and I needed to write a test to make sure it worked the way I thought it would work and also to document how to use the subsystem. So I created a small test hierarchy and plugged in the EngineTrustTest:

src
  test
    java
      org.guanxi.sp.engine.trust.EngineTrustTest
    …

String metadataURL = "file:///" + new File(EngineTrustTest.class.

getResource(“/metadata.xml”).getPath()).getCanonicalPath();

I then ran mvn clean install, sat back and thought of a coffee. Then I got the NPE on the above line of code. WTF? I compared poms with the IdP build. I compared directory layout with the IdP layout, which uses the same technique to load resources from the test classpath. The test ran fine in IDEA. It barfed from the maven commandline. I rummaged, I ranted, I jumped up and down and with the hooting of an owl outside I decided enough was enough and went to bed.

Next morning, munching brekkers and waiting for the coffee to brew a thought came into my head, completely out of nowhere. Here I was reading the latest rant from the Prof in the WHFP, about the latest Labour infighting and something in my head shouted, “You’ve misspelled the resources directory!”. WOW! excuse me? who are you? can you wait ‘til I’ve finished my cornflakes please? But I couldn’t. I rushed over to the machine and sure enough:

src
  test
    java
    resouces
resouces instead of resources.

Unit tests are a great way to verify everything’s tickety-boo and to document how to use a system but when you need to test the tests, just hit the sack and wait for the answer to bubble up from the depths.

comments powered by Disqus