Question: Please answer the following questions: Use the following code to answer questions 2 - 4 : public int Fun ( int x , int k

Please answer the following questions:
Use the following code to answer questions 2-4:
public int Fun(int x, int k, int y){
int i =0;
while (i < x){
if (x/2<2){
k = y - x;
k = y + i;
}
else{
x = k -2;
y = y + x;
}
k = x + y;
i = i +2;
}
if (x <0|| y <0){
k = y - x;
}
else{
k = y + x;
}
return k;
}
2. Draw a flow graph to represent the method Fun. Label the nodes (starting with A) and the outgoing edges of the decision boxes appropriately.
A
/\
/\
B C
/\/\
/\/\
D E F
\/\/
\/\/
G H
\/
\/
I
3. Identify the set P of paths in the flow graph for Fun and a set of test inputs that satisfy 100% for each of the following criteria. You are required to show trace tables for each set of inputs used to achieve the criteria. If 100% coverage cannot be obtained, explain why.
i. statement coverage
ii. branch coverage
iii. multiple condition coverage (MCC)
4. Compute the number of basis paths in the flow graph in Question 2
Use the following mutant of the code above to answer questions 57:
1. public int Fun(int x, int k, int y){
2. int i =0;
3. while (i < x){
4. if (x/2<2){
5. k = y - x;
6. k = y + i;
7.}
8. else{
9. x = k -2;
10. y = y - x;
11.}
12. k = x + y;
13. i = i +2;
14.}
15. if (x <0|| y <0){
16. k = y x;
17.}
18. else{
19. k = y + x;
20.}
21. return k;
22.}
5. Identify two (2) test cases (two pairs of (x, y)) that strongly kill the mutant above. Clearly show the inputs and the outputs for each test case. Use appropriate trace tables to show how the mutants were killed.
6. Apply a mutation mathematical operator (e.g.,+,-,/,...) to the code in questions 3 whereby no input will strongly kill the mutant. Describe the change that was made, i.e. state the line number and what change was made.
7. Identify two (2) test cases that weakly kill the mutant described in part (b). Use appropriate trace tables to show how the mutants were killed.
If you cannot find a solution to any of the questions above provide an explanation why it is not possible
8. Write well-documented JUnit test cases and a well-documented Java class containing the method Fun in Question 2, and show the code coverage obtained when executing the test cases developed for:
i. statement coverage (place in class name StmntCov)
ii. branch coverage (place in class name BranchCov)
write a well-documented code in an IDE, e.g., Eclipse. Copy and paste the code for the files (Question 2 code and the Junit test cases). Take a screen shot of the code coverage (statement and branch) and paste it after the code. Note you should have 4 screen shots: 2 showing statement (line) coverage and branch coverage for the test cases in Q3(i); and 2 screen shots for statement (line) coverage and branch coverage for the test cases in Q3(ii).
9. Write well-documented JUnit test cases and a well-documented Java class containing the mutant of the method Fun in Question 5.
i. Compare the 2 JUnit test cases and describe the differences between them.
ii. Did you find a way to create JUnit test cases that identify a mutant in your code? If so, how was it helpful in determining the best way to kill a mutation?
Please answer all the questions with this flow graph from 3-9. Thanks

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!