views:

457

answers:

1

I am working on a java message queue client (beanstalk) and right now my tests look like this:

  //make sure our getJob can handle utf8 characters
  @Test
  public void testUTF8() {
    bean = new Beanstalk();
    Job job = new Job();
    bean.putJob("€");
    job = bean.getJob();
    assertEquals("€", job.msg);
    bean.close();
  }

I've read that you shouldn't test the actual queue itself cause it's not code that I write but I DO write the client code -- is there a better way to write this? I really need the tests to assure myself but besides style it's also a pain in the ass to setup for my CI.

+2  A: 

I don't think there's anything wrong with writing unit tests to determine/document the behavior of an external library. If you include that test in your code base, then you have a record of the fact that your queue needs to support UTF8; if you change to a different queueing mechanism in the future, that test will break and need to be rewritten, forcing the implementer of the new queueing mechanism to consider whether the new system can also handle UTF8. That's a good thing, in my opinion.

As for setting this up in your CI, my suggestion is that you classify this as an integration test and run it on a CI machine that has queueing support installed, if you have one.

MattK