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