1 package junit.samples; 2 3 import junit.framework.*; 4 5 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 36 37 40 return new TestSuite(SimpleTest.class); 41 } 42 public void testAdd() { 43 double result= fValue1 + fValue2; 44 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 } | Popular Tags |