Tag: junit 5 exception

  • JUnit: Assert Exceptions

    JUnit: Assert Exceptions

    When writing JUnit, at times you would want to check methods for exceptions. Here’s how you do it. In below method, we divide 2 numbers and throw error if second argument of method is zero. public static double div(double x, double y) { if(y == 0) { throw new ArithmeticException(“divide by zero”); } return (double)(x/y);…