Question: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and

 /* * To change this license header, choose License Headers in /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package junitexercise;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author issam.alazzoni
*/
public class JUnitExerciseTest {
public JUnitExerciseTest() {
}
/**
* Test of sum method, of class JUnitExercise.
*/
@Test
public void testSum() {
System.out.println("sum");
/* TC1 */
int[] a = {1};
int n = 1;
int expResult = 1;
int result = JUnitExercise.sum(a, n);
assertEquals("TC1",expResult, result);
/* TC2 */
n = 0;
expResult = 4;
result = JUnitExercise.sum(a, n);
assertEquals("TC2",expResult, result);
}
}

Part 1: Consider the code of the method printString(String s, int n) which implements the specification of the first question in Assignment 1. The method has two parameters: the string s and the integer n. a. Draw a control flow graph for the program and clearly label each node to show its correspondence to a statement. b. Calculate the program's cyclomatic complexity. What does this mean in terms of the number of test cases to cover the code with respect to its branches? c. Develop a set of test cases to achieve full decision coverage. For each test case, you must provide the input values and the expected output in addition to the covered path. Fill the following table: Test Case Input Identifier Values Expected Actual Outputs Outputs Test Case Path Covered Result Pass Fail public static String printString(Strings, int n) Strings if (call 95) ERROR IN INPUTS"; else if( null Il s.length()3 Il s.length() ) ERROR INPUTS else if(Character is Alphabetics.charte() STORIES: else if (Character is ghabetics.chart (1) Il Character is igit(s.chant (1) (Character is Alphabetics.chant (2) Il Characteristigits.chart()))) for(int i; ;-) Part 2: a. Implement the test cases you identified in Part 1.c as JUnit test cases. Part 1: Consider the code of the method printString(String s, int n) which implements the specification of the first question in Assignment 1. The method has two parameters: the string s and the integer n. a. Draw a control flow graph for the program and clearly label each node to show its correspondence to a statement. b. Calculate the program's cyclomatic complexity. What does this mean in terms of the number of test cases to cover the code with respect to its branches? c. Develop a set of test cases to achieve full decision coverage. For each test case, you must provide the input values and the expected output in addition to the covered path. Fill the following table: Test Case Input Identifier Values Expected Actual Outputs Outputs Test Case Path Covered Result Pass Fail public static String printString(Strings, int n) Strings if (call 95) ERROR IN INPUTS"; else if( null Il s.length()3 Il s.length() ) ERROR INPUTS else if(Character is Alphabetics.charte() STORIES: else if (Character is ghabetics.chart (1) Il Character is igit(s.chant (1) (Character is Alphabetics.chant (2) Il Characteristigits.chart()))) for(int i; ;-) Part 2: a. Implement the test cases you identified in Part 1.c as JUnit test cases

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!