01: package org.junit.samples;
02:
03: import static org.junit.Assert.assertEquals;
04: import junit.framework.JUnit4TestAdapter;
05: import org.junit.Before;
06: import org.junit.Test;
07:
08: /**
09: * Some simple tests.
10: *
11: */
12: public class SimpleTest {
13: protected int fValue1;
14: protected int fValue2;
15:
16: @Before
17: public void setUp() {
18: fValue1 = 2;
19: fValue2 = 3;
20: }
21:
22: public static junit.framework.Test suite() {
23: return new JUnit4TestAdapter(SimpleTest.class);
24: }
25:
26: @Test
27: public void divideByZero() {
28: int zero = 0;
29: int result = 8 / zero;
30: result++; // avoid warning for not using result
31: }
32:
33: @Test
34: public void testEquals() {
35: assertEquals(12, 12);
36: assertEquals(12L, 12L);
37: assertEquals(new Long(12), new Long(12));
38:
39: assertEquals("Size", 12, 13);
40: assertEquals("Capacity", 12.0, 11.99, 0.0);
41: }
42:
43: }
|