JUnit 4, the downfall

Sadly, after my excitement about Junit 4, I’ve found the downfall: it doesn’t work with ant yet.

However, there does appear to be a workaround. Add this to each class:

  public static junit.framework.Test suite() {
    return new junit.framework.JUnit4TestAdapter(SimpleTest.class);
  }

However, that’s now causing my tests to fail with NullPointerExceptions inside HttpUnit. Yet they work fine in Eclipse. Wonder what I’m doing wrong?

Update: It’s entirely my own fault—my ant task was forgetting to copy over non-java artifacts into the classpath. So adding suite() makes things work just fine.

Comments are Closed