package com.example.maths; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; public class MathsTest { private Maths maths; @BeforeEach void setUp() { maths = new Maths(); } @Test void testFactorial() { assertEquals(1, maths.factorial(0), "Factorial of 0"); assertEquals(1, maths.factorial(1), "Factorial of 1"); assertEquals(120, maths.factorial(5), "Factorial of 5"); } @Test void testDivideByZeroThrowsException() { ArithmeticException exception = assertThrows(ArithmeticException.class, () -> { maths.divide(10, 0); }); assertEquals("/ by zero", exception.getMessage()); } }