Question: This is using Java JUnit public static double square Root(double num) { return Math.sqrt(num); Test value for num Expected result assertEquals() What about negative numbers????

This is using Java JUnit

This is using Java JUnit public static double square Root(double num) {

public static double square Root(double num) { return Math.sqrt(num); Test value for num Expected result assertEquals() What about negative numbers???? Let's rewrite the code public static double square Root(double num) { if (num >= 0) { return Math.sqrt(num); else { return -99; Test value for num Expected result assertEquals() Now rewrite the code so it throws and exception and catches it in main How would you write a Junit test for this

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!