Question: For the average function do the following: - - - - - - - - - - - - - - - - - -

For the "average" function do the following:
------------------------------------------------------------------------------------------------------------------
public class Average {
public int average(int k, int[] list){
int average =0;
int n = Math.min(k, list.length);
if( n >0){
for(int i =0 ; i < n; i++){
average += list[i];
}
average = average/n;
}
return average;
}}
-------------------------------------------------------------------------------------------------------------------
(10pts) Write a brief functional description for the function.
(10pts) Generate functional test case based on functional description.
(10pts) Identify and specify the partitions and generate partition test cases.
(10pts) Generate boundary value test cases.
(10pts) Implement the average function in a class Average and generate test cases usingJunit.
(25 pts) Compile and run the test cases. Record any failures and errors that are reported. Analyze and briefly explain why each of the failures and errors occurs and how you fix them. Correct all the failures and errors until the CUT (Component Under Test) passes all the test cases.
In case there is no failiure, please inject a fault yourself and complete the section f.(That means you need to inject a fault in this average method, and see if your tests can find the fault. For example, instead of i=0, change the code to i=1, or instead of min , use max .. these faults cause the function to not behave as you describe in the section a, and since you design your tests according to this description , your test should be able to reveal the fault and fail. but if your test did not fail after you inject the fault, then you need to redesign and add a new test to reveal your injected fault.)
(25 pts) Measure the code coverage using a code coverage tools such as EclEmma. Your test case must achieve 100% branch coverage.
Cobertura is described in Appendix CEclEmma is a Java code coverage analysis for the Eclipse IDE. Check http://www.eclemma.org/ for updates, documentation and support.

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 Programming Questions!