1 package junit.samples;
2
3 import junit.framework.Test;
4 import junit.framework.TestCase;
5 import junit.framework.TestSuite;
6
7
8
9
10 public class SimpleTest extends TestCase {
11 protected int fValue1;
12 protected int fValue2;
13
14 @Override
15 protected void setUp() {
16 fValue1 = 2;
17 fValue2 = 3;
18 }
19
20 public static Test suite() {
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 return new TestSuite(SimpleTest.class);
44 }
45
46 public void testAdd() {
47 double result = fValue1 + fValue2;
48
49 assertTrue(result == 6);
50 }
51
52 public int unused;
53
54 public void testDivideByZero() {
55 int zero = 0;
56 int result = 8 / zero;
57 unused = result;
58 }
59
60 public void testEquals() {
61 assertEquals(12, 12);
62 assertEquals(12L, 12L);
63 assertEquals(new Long(12), new Long(12));
64
65 assertEquals("Size", 12, 13);
66 assertEquals("Capacity", 12.0, 11.99, 0.0);
67 }
68
69 public static void main(String[] args) {
70 junit.textui.TestRunner.run(suite());
71 }
72 }