Login | Register
My pages Projects Community openCollabNet

Error Notification

In our imaginary scenario, let's assume that we have a new feature request. Users want getTopN to return the best n items, even if the list passed in is not sorted. So far, none of our tests uses a clearly unsorted list as input to getTopN. So let's add one to TopTenTest.java:

  public void testTopThreeIntsUnsorted() {
    Integer one = new Integer(1);
    Integer two = new Integer(2);
    Integer three = new Integer(3);
    Integer four = new Integer(4);
    Integer five = new Integer(5);
    Integer six = new Integer(6);

    assertEquals(
        Arrays.asList(new Integer[] { one, two, three }),
        TopTen.getTopN(
            3,
            Arrays.asList(new Integer[] { four, one, two, three, five, six })));
  }

We don't expect this test to pass. Save the file, and soon, continuous testing springs into action. You'll see several indications of the failing test, similar to what you see when there is a compile error in your code:

  • A problem has been added to the problems view. The icon for this problem is a red ball, just like a compile error. However, this one has a T for "test failure":
  • Double-clicking the failure in the problems view will open and highlight the test method that failed. Notice that the method name is marked with a wavy red underline, and a in the margin.

Although the same kind of notifications are used for compile errors and test failures, the two kinds of problems are different. Most importantly, compile errors are usually indicated near the code that needs to be changed, whereas test failures are indicated on the test method that failed. To fix a test failure will often require making a change in the code being tested, somewhere far away from the failure notification.