| 10 | import onjava.*; |
| 11 | |
| 12 | public class AtUnitExample5 { |
| 13 | private String text; |
| 14 | public AtUnitExample5(String text) { |
| 15 | this.text = text; |
| 16 | } |
| 17 | @Override public String toString() { return text; } |
| 18 | @TestProperty |
| 19 | static PrintWriter output; |
| 20 | @TestProperty |
| 21 | static int counter; |
| 22 | @TestObjectCreate |
| 23 | static AtUnitExample5 create() { |
| 24 | String id = Integer.toString(counter++); |
| 25 | try { |
| 26 | output = new PrintWriter("Test" + id + ".txt"); |
| 27 | } catch(IOException e) { |
| 28 | throw new RuntimeException(e); |
| 29 | } |
| 30 | return new AtUnitExample5(id); |
| 31 | } |
| 32 | @TestObjectCleanup |
| 33 | static void cleanup(AtUnitExample5 tobj) { |
| 34 | System.out.println("Running cleanup"); |
| 35 | output.close(); |
| 36 | } |
| 37 | @Test |
| 38 | boolean test1() { |
| 39 | output.print("test1"); |
| 40 | return true; |
| 41 | } |
| 42 | @Test |
| 43 | boolean test2() { |
| 44 | output.print("test2"); |
| 45 | return true; |
| 46 | } |
| 47 | @Test |
| 48 | boolean test3() { |
| 49 | output.print("test3"); |
| 50 | return true; |
| 51 | } |
| 52 | } |
| 53 | /* Output: |
| 54 | annotations.AtUnitExample5 |
| 55 | . test1 |
nothing calls this directly
no outgoing calls
no test coverage detected