View Test Results.
package cs221.groupk.common; import java.io.*; import java.util.*; /** * ModuleTestHarness is a generic test harness. This class is extended, with * the three final Strings being replaced, and the test() method being overridden. * * @author <A HREF="mailto:[email protected]">Paul Smith</A> */ public abstract class ModuleTestHarness { /**outFile is used as a place holder for the file used to write output to*/ protected File outFile; /**out is the class responsible for writing data to disk*/ protected BufferedWriter out; /**data is a Date object to allow date/time stamping of test runs*/ protected Date date = new Date(); /** * execute is the first non-static method called by <CODE>main</CODE>. The * output file is initilised here, so from <CODE>test</CODE> out is available, * e.g: * <P> * <PRE><CODE> * public void test() throws IOException * { * out.write("Example output"); * } * </PRE></CODE> */ public int execute(String classAuthor, String className, String outputFile) { System.out.print("Testing " + className +"... "); try { outFile = new File(outputFile); out = new BufferedWriter(new FileWriter(outFile.getPath(), false)); out.write("Module Testing.\nModule: " + className + " - " + classAuthor + ".\nTested on: " + date.toString() +".\n\n"); test(); System.out.println("done."); System.out.println("Written to: " + outFile.toString()); } catch(Exception outputException) { System.out.println("failed."); return -1; } finally { try { out.flush(); out.close(); } catch(IOException ioe) {} } return 0; } /** * test is the method that is overriden when creating a new harness. * @exception IOException can be thrown if there is a problem with the * BufferedWriter saving to file. */ public void test() throws IOException { } /** * main is the executable bootstrap method called by the Java VM. * @param String[] arguments from the command line. */ public static void main(String[] args) throws IOException { } }Page automatically generated on: 26/01/01 at: 10:48:15.