Browse Source

Test: added testReadFromFile() for the professor Data

remotes/origin/fdai7780
fdai7600 11 months ago
parent
commit
8133f81a6f
  1. 20
      src/test/java/org/example/ProfessorTest.java

20
src/test/java/org/example/ProfessorTest.java

@ -1,4 +1,24 @@
package org.example; package org.example;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.List;
import static org.junit.Assert.assertEquals;
public class ProfessorTest { public class ProfessorTest {
@Test
void testReadFromFile() throws IOException {
Professor professor = new Professor("P1002", "Jane Doe", "Professor");
professor.writeToFile();
List<Professor> professors = Professor.readFromFile();
assertEquals(1, professors.size());
assertEquals("P1002", professors.get(0).getProfessorID());
assertEquals("Jane Doe", professors.get(0).getName());
assertEquals("Professor", professors.get(0).getRole());
}
} }
Loading…
Cancel
Save