1 package TestSuite; 2 3 import java.io.*; 4 import java.util.*; 5 6 /* 7 * C/C++ Users Journal Sept 2000 <br> 8 * The Simplest Automated Unit Test Framework That Could Possibly Work <br> 9 * Chuck Allison <br> 10 */ 11 public final class Suite 12 { 13 String name; 14 BufferedWriter sink; 15 ArrayList tests = new ArrayList(); 16 Suite(String name)17 public Suite(String name) 18 throws IOException 19 { 20 this.sink = 21 new BufferedWriter( 22 new OutputStreamWriter(System.out) 23 ); 24 this.name = name; 25 } Suite(String name, BufferedWriter sink)26 public Suite(String name, 27 BufferedWriter sink) 28 { 29 this.sink = sink; 30 this.name = name; 31 } 32 addTest(Test t)33 public void addTest(Test t) 34 { 35 t.setSink(sink); 36 tests.add(t); 37 } 38 run()39 public void run() 40 throws IOException 41 { 42 for (int i = 0; i < tests.size(); ++i) 43 { 44 Test t = (Test) tests.get(i); 45 t.run(); 46 } 47 } report()48 public void report() 49 throws IOException 50 { 51 for (int i = 0; i < tests.size(); ++i) 52 { 53 Test t = (Test) tests.get(i); 54 t.report(); 55 } 56 sink.flush(); 57 } flush()58 public void flush() 59 throws IOException 60 { 61 sink.flush(); 62 } 63 close()64 public void close() 65 throws IOException 66 { 67 sink.close(); 68 } 69 } 70