diff --git a/src/test/java/org/example/StudentTest.java b/src/test/java/org/example/StudentTest.java index 89d4d40..256b017 100644 --- a/src/test/java/org/example/StudentTest.java +++ b/src/test/java/org/example/StudentTest.java @@ -26,7 +26,11 @@ class StudentTest { } -@Test + + + + + @Test void readFromFile() throws IOException { try (PrintWriter writer = new PrintWriter(new FileWriter("testStudentData.txt"))){ @@ -51,6 +55,23 @@ class StudentTest { } + @Test + void printStudentInfo() { + Student student = new Student("Sebastian", "S1001", "Student"); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStream)); + + student.printStudentInfo(); + + String printedOutput = outputStream.toString().trim(); + + assertTrue(printedOutput.contains("Sebastian")); + assertTrue(printedOutput.contains("S1001")); + assertTrue(printedOutput.contains("Student")); + + } + } \ No newline at end of file