diff --git a/src/test/java/org/example/StudentTest.java b/src/test/java/org/example/StudentTest.java index e97e7d0..89d4d40 100644 --- a/src/test/java/org/example/StudentTest.java +++ b/src/test/java/org/example/StudentTest.java @@ -25,4 +25,32 @@ class StudentTest { Files.delete(path); } + +@Test + void readFromFile() throws IOException { + + try (PrintWriter writer = new PrintWriter(new FileWriter("testStudentData.txt"))){ + writer.println("Samuel"); + writer.println("S1001"); + writer.print("Student"); + } catch (IOException e) { + e.printStackTrace(); + } + String filename = "testStudentData.txt"; + List testStudents = Student.readFromFile(filename); + + assertEquals(1, testStudents.size()); + Student admin = testStudents.get(0); + + assertEquals("Samuel", admin.getName()); + assertEquals("S1001", admin.getId()); + assertEquals("Student", admin.getRole()); + + Files.delete(Path.of(filename)); + + } + + + + } \ No newline at end of file