Category: JUnit
-
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);…
-
Basic JUnit 5
I have tried learning from various tutorials for JUnit and all tutorials went into unnecessary aspects of JUnit which are useful but not for someone who is looking to grab JUnit understanding quickly and knows Java. So I am writing this tutorial for someone who is looking to grab JUnit concepts and knows Java. Let’s…