Adding unit test for Student grade
@@ -4,6 +4,8 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import com.baeldung.accessmodifiers.publicmodifier.ListOfThree;
+import com.baeldung.accessmodifiers.publicmodifier.Student;
+
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -28,6 +30,15 @@ public class PublicAccessModifierUnitTest {
assertEquals(2147483647, Integer.MAX_VALUE); //static field
}
+ @Test
+ public void whenChangingStudentInternalRepresentation_clientCodeWillNotBreak() {
+
+ Student student = new Student();
+ student.setGrade(100);
+
+ assertEquals(100, student.getGrade());
+ }
+
@Test
public void whenUsingEntrySet_keyValuePairsAreReturned() {
