MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / AtUnitExample5

Class AtUnitExample5

annotations/AtUnitExample5.java:12–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10import onjava.*;
11
12public 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:
54annotations.AtUnitExample5
55 . test1

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected