From 3c5c5e0ef5549ac9e343208c2e14d32084498b92 Mon Sep 17 00:00:00 2001 From: jannisfingerhut Date: Fri, 10 Feb 2023 23:22:59 +0100 Subject: [PATCH] #32 UnitTest --- LernProgramm/testProgramm.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/LernProgramm/testProgramm.java b/LernProgramm/testProgramm.java index 16652e1..a8be895 100644 --- a/LernProgramm/testProgramm.java +++ b/LernProgramm/testProgramm.java @@ -86,6 +86,20 @@ class testProgramm { assertEquals(1, result, 0); } +@Test + public void testFakultaetWithPositiveNumber() { + String input = "5\n"; + ByteArrayInputStream in = new ByteArrayInputStream(input.getBytes()); + System.setIn(in); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + System.setOut(new PrintStream(out)); + + FunktionenAusgelagert.Fakultaet(); + + assertEquals("120\n", out.toString()); + } +