|
|
@ -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")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |