package StudentPkg; /** StudentTest.java * This class tests the Student class using the JUnit package * Written by: Stuart Hansen * Date: October 3, 2002 **/ import junit.framework.*; public class StudentTest extends TestCase { private Student student; // the application object // the constructor constructs the test case public StudentTest(String name) { super(name); } // setUp is called to initialize things before the test protected void setUp () { student = new Student("Stu", 70, 100, 100); } // tearDown is called after the test protected void tearDown() { student = null; } // test the toString method public void testToString() { String s = student.toString(); assertTrue(s.equals("Stu 70 100 100")); } // test getName public void testGetName() { String s = student.getName(); assertTrue(s.equals("Stuart")); } // test setName public void testSetName() { student.setName("Erica Eddy"); assertTrue(student.getName().equals("Erica Eddy")); } // test getAverage public void testGetAverage() { double avg = student.getAverage(); assertTrue(avg == 90); } // What other tests should be run for this class?? // Combine all our tests into a suite public static Test suite() { return new TestSuite(StudentTest.class); } }