Computer Science 1
Top Lectures Assignments Noticeboard

Testing and Debugging

Reading: Chapter 7

Categories of errors

Compilation errors

Runtime errors

Logic errors

Test Drivers

class Date {
  ...
  public void testDriver () {
    Date d1 = new Date (31,12,1998, true);
    System.out.print ("The next date should be 1/1/1999: ");
    d1.nextDay (); d1.print ();
    Date d2 = new Date (28,2, 2000, true);
    System.out.print ("The next date should be 3/1/2000: ");
    d2.nextDay (); d2.print ();
    Date d3 = new Date (28, 2, 1996, true);
    System.out.print ("The next date should be 2/29/1996: ");
    d3.nextDay (); d3.print ();
    if (d1.lessThan (d3)) {
      System.out.println ("There is an error in lessThan.");
    } else {
      System.out.println ("lessThan works for:");
      d1.print ();
      d3.print ();
    }
    ...
  }
}
What to test:

Debugging


Last modified: 2/21/99