Bill Roper (billroper) wrote,
Bill Roper

That's Improbable!

So I wrote a new method for the project that I've been working on. It wasn't an overly complex method, but it was slightly annoying to write and might actually have been written in some "doomed to fail" way by mistake, so I said to myself, "Well, self, why don't you just write a unit test and make sure that it works?"

This was a good question with a simple answer, so I wrote the unit test. After a bit of futzing around with types (generics were in play), I got the unit test to work and determined that the new method was putting out what it was supposed to given the inputs I had given it. Good enough.

Let me go add it to the list of unit tests so that it will get run when I check this mess in again.

Hey, as long as I'm adding the unit test to the list, let's run the subset of unit tests that exercise my code.

Why are these unit tests failing?

It turns out that I had made a change that converted an ISO currency code I was using from upper case to lower case. This would seem harmless and -- in some better universe -- it would be. However, the Java Currency.getInstance() method stubbornly insists that it is only going to play nice if the currency code is in upper case.

I have patched the code so that the currency code is now upper case again.


So much to my surprise, a unit test has done what it was supposed to do. This is a first in my experience...
Tags: java, musings, testing, work

  • Steps

    Today is better than yesterday. Still short on solutions, but maybe I can get some time to sort things out. Thanks, folks.

  • Well, That Escalated Quickly

    Today could have been better. Much better.

  • The More You Know

    The problem with getting older is that -- although you may know more than you did when you were younger -- it seems like there are more and more…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded