Question: This criterion is linked to a Learning OutcomejUnit tests for harmonic Compiling test class including import statements and at least one test method with the


This criterion is linked to a Learning OutcomejUnit tests for harmonic Compiling test class including import statements and at least one test method with the @Test annotation Write five different JUnit tests that use assertions to test both valid and invalid input Declare a private final field called DELTA, assign it a billionth, and use it to compare the expected and actual values. Use descriptive test method names.
In this second part of the assignment, you will write JUnit5 tests for an existing method. Add a fourth static method to the class Recursion. Its name is harmonic, it has one parameter n of type int, and the return type is double. The method is supposed to do the following: If n is positive, the method should return the n-th harmonic number, which is calculated like this: 1/1 + 1/2 + 1/3 + ... + 1. If n is negative, the method should return the additive inverse of the n-th harmonic number. If n is zero, an IllegalArgumentException should be thrown. Rather than implementing the method, copy this implementation into your code. If you need to adjust the indentation, go to Eclipse > Source > Format. It might be able to fix the indentation for you. Add a JUnit test file called Harmoictest to the source folder called test. Write at least five different JUnit test methods to test the method harmonic using both valid and invalid input. Choose the tests deliberately to provide thorough testing that uncovers as many potential problems as possible. Each of the five JUnit test methods should have a descriptive name that indicates what it is testing for. Add a fourth static method to the class Recursion. Its name is harmonic, it has one parameter n of type int, and the return type is double. Method harmonic public static double harmonic (int n) { if (n == 0) throw new IllegalArgumentException ("The argument n can't be zero."); if (n == 1) return 1; else if (n 1 return 1.0 + harmonic (n 1); } and invalid input Choose the tests deliberately to provide thorough testing that uncovers as many potential In this second part of the assignment, you will write JUnit5 tests for an existing method. Add a fourth static method to the class Recursion. Its name is harmonic, it has one parameter n of type int, and the return type is double. The method is supposed to do the following: If n is positive, the method should return the n-th harmonic number, which is calculated like this: 1/1 + 1/2 + 1/3 + ... + 1. If n is negative, the method should return the additive inverse of the n-th harmonic number. If n is zero, an IllegalArgumentException should be thrown. Rather than implementing the method, copy this implementation into your code. If you need to adjust the indentation, go to Eclipse > Source > Format. It might be able to fix the indentation for you. Add a JUnit test file called Harmoictest to the source folder called test. Write at least five different JUnit test methods to test the method harmonic using both valid and invalid input. Choose the tests deliberately to provide thorough testing that uncovers as many potential problems as possible. Each of the five JUnit test methods should have a descriptive name that indicates what it is testing for. Add a fourth static method to the class Recursion. Its name is harmonic, it has one parameter n of type int, and the return type is double. Method harmonic public static double harmonic (int n) { if (n == 0) throw new IllegalArgumentException ("The argument n can't be zero."); if (n == 1) return 1; else if (n 1 return 1.0 + harmonic (n 1); } and invalid input Choose the tests deliberately to provide thorough testing that uncovers as many potential
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
