View Javadoc
1   package org.junit.samples;
2   
3   import static org.junit.Assert.assertEquals;
4   
5   import junit.framework.JUnit4TestAdapter;
6   import org.junit.Before;
7   import org.junit.Test;
8   
9   /**
10   * Some simple tests.
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      public int unused;
27  
28      @Test
29      public void divideByZero() {
30          int zero = 0;
31          int result = 8 / zero;
32          unused = result; // avoid warning for not using result
33      }
34  
35      @Test
36      public void testEquals() {
37          assertEquals(12, 12);
38          assertEquals(12L, 12L);
39          assertEquals(new Long(12), new Long(12));
40  
41          assertEquals("Size", 12, 13);
42          assertEquals("Capacity", 12.0, 11.99, 0.0);
43      }
44  
45  }