/** * The test class StudentTest -- it tests the Student class * * @author Phill Conrad, and (insert your name here) * @version lab02 for CS10, Spring 2009. * @see Student */ public class StudentTest extends junit.framework.TestCase { public void testConstructorAndGetters() { // set up a student with the constructor, and // then make sure that the getters retrieve the // values that we expect the new object to have Student s = new Student("Fred Smith",1234567); assertEquals("Fred Smith",s.getName()); assertEquals(1234567,s.getPermNumber()); } public void testConstructorSetAndGetName() { // set up a student with the constructor, set // the values to something else, then then // see if the values are what we expect them to be. Student s = new Student("Chris Jones",9999999); s.setName("Fred Smith"); assertEquals("Fred Smith",s.getName()); } public void testConstructorSetAndGetPermNumber() { // set up a student with the constructor, set // the values to something else, then then // see if the values are what we expect them to be. Student s = new Student("Chris Jones",9999999); s.setPermNumber(1234567); assertEquals(1234567,s.getPermNumber()); } public void testToString() { // set up a student with the constructor, // and see if the toString method returns what // we expect to see Student s = new Student("Chris Jones",9999999); assertEquals("(name: Chris Jones, perm: 9999999)", s.toString()); } }