unit testing unit = method write main (stub) explicitly to test (call) the method get values for testing random generation loop to generate literals for special cases user input (files to retest (regression testing), redirection of input) special cases: valid values (positive test), invalid values (negative test), boundary cases white-box testing: see function, test every branch black-box testing: blind test, try to break code evaluating output - look & evaluate - calculate by hand (calculator) - compare result to another known method for computing value = oracle - do problem backwards/inverse operation FINDING & FIXING ERRORS IN PROGRAM - software/application debuggers - run until checkpoint - inspect variable - step through line by line - step over - in-code debugging tricks - print statements to see variable values - new Throwable().printStackTrace() - throw new IllegalArgumentException() public class Check { public static void assert(boolean condition) { if (!condition) { new Throwable().printStackTrace(); // throw new IllegalArgumentException(); System.exit(1); } } } public class blah { public static void main ... { Check.assert(denominator != 0); } }