Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use Junit and Eclipse environment to finish the following questions. (15pts) Review the slides and add Junit library before running your tests. You need to

Use Junit and Eclipse environment to finish the following questions. (15pts)

Review the slides and add Junit library before running your tests. You need to create a new Project first, and then add the files.

Due date: November 6th, Monday. 11:59pm. Submit all screenshots of test result and test files.

1-Use the following code and write a test file called FactorialExceptionTest.java for the following factorial function. Test if it will throw an IllegalArgumentException exception if the parameter of the function is -3. (5pts)

/**

* Calculate the factorial of a number

*/

public class Factorial_1 {

public int factorial(int n) {

if (n < 0)

throw new IllegalArgumentException( "factorial cannot handle negative numbers!!" );

if (n == 0)

return 1;

else

return n * factorial(n - 1);

}

}

2-Write a parameterized test for the factorial function in question 1. Note: remember to import necessary packages. And your test class needs to test the factorial of four numbers: 3, 4, 2, 5 (5pts)

3-Write a test suite FactorialTest.java that includes the test files you wrote in question 1, and 2. (5pts)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Catch your employees doing a good job.

Answered: 1 week ago

Question

Prepare a short profile of Henry words worth Longfellow?

Answered: 1 week ago

Question

What is RAM as far as telecommunication is concerned?

Answered: 1 week ago

Question

Question 1: What is reproductive system? Question 2: What is Semen?

Answered: 1 week ago

Question

Describe the sources of long term financing.

Answered: 1 week ago