diff --git a/src/test/java/org/example/StudentTest.java b/src/test/java/org/example/StudentTest.java new file mode 100644 index 0000000..e97e7d0 --- /dev/null +++ b/src/test/java/org/example/StudentTest.java @@ -0,0 +1,28 @@ +package org.example; + +import org.junit.jupiter.api.Test; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; +class StudentTest { + + @org.junit.jupiter.api.Test + void writeToFile() throws IOException { + Student student = new Student("Sebastian", "S1001", "Student") ; + + String filename = "testStudentData.txt"; + + student.writeToFile(student, filename); + + Path path = Path.of(filename); + String content = Files.readString(path); + assertEquals("Sebastian\nS1001\nStudent", content); + + Files.delete(path); + + } +} \ No newline at end of file