// Project: Classes // Module: person // Source code file Test2.java // Unit test file for Person class. import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; class Test2 { // Define p as an instance variable so that // it is available in all methods. Person p; // Instantiate p so that the object is // available in all test methods. @BeforeEach void setUp( ) { p = new Person("Alice", 'F', 11); } // Test getName method. @Test void testGetName( ) { assertEquals("Alice", p.getName( )); } // Test getGender method. @Test void testGetGender( ) { assertEquals('F', p.getGender( )); } // Test getAge method. @Test void testGetAge( ) { assertEquals(11, p.getAge( )); } // Test setAge method. @Test void testSetAge( ) { p.setAge(10); assertEquals(10, p.getAge( )); } // Test haveBirthday method. @Test void testHaveBirthday( ) { p.haveBirthday( ); assertEquals(12, p.getAge( )); } // Test test toString method. @Test void testToString( ) { assertEquals("Alice F 11", p.toString( )); } }