diff --git a/pom.xml b/pom.xml index 2d767b6..a8fb3e3 100644 --- a/pom.xml +++ b/pom.xml @@ -13,5 +13,19 @@ 19 UTF-8 + + + junit + junit + 4.13.1 + test + + + org.junit.jupiter + junit-jupiter + 5.8.1 + test + + \ No newline at end of file diff --git a/src/test/java/org/example/AdminTest.java b/src/test/java/org/example/AdminTest.java new file mode 100644 index 0000000..0c964fe --- /dev/null +++ b/src/test/java/org/example/AdminTest.java @@ -0,0 +1,26 @@ +package org.example; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +import static org.junit.jupiter.api.Assertions.*; + +class AdminTest { + + @org.junit.jupiter.api.Test + void printAdminInfo() { + Admin admin = new Admin("Aaron", "A1001", "Admin"); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStream)); + + admin.printAdminInfo(); + + String printedOutput = outputStream.toString().trim(); + + assertTrue(printedOutput.contains("Aaron")); + assertTrue(printedOutput.contains("A1001")); + assertTrue(printedOutput.contains("Admin")); + + } +} \ No newline at end of file