CS 4500 Software Development Structural Testing Homework

Please submit all files in your private class repo under a hmk6 directory. 1. Given the following method, consolidateSpace,
a) Construct its CFG (hand-drawn is fine, but it must be NEAT). b) Cut and paste the code into your IDE of choice.
c) Using a test harness (junit is strongly preferred),
i. Develop a set of test cases that will meet 100% code coverage.
ii. Develop a set of test cases that will meet 100% branch coverage.
iii. What is the bug in the code? Where in the CFG is it and which test(s) illumi- nated it? There may be more than one bug.
Submit your CFG, project directory, reports covering (i) and (ii), and document discussing (iii). (50 points)
public class Example {
@NotNull
public static String consolidateSpace (String inputText) {
/* replace all multiple contiguous spaces with a single space *
* @param String
* @return String */
String result = “”;
boolean foundSpace = false;
System.out.println(“Input: ” + inputText);
for (int i = 0; i < inputText.length(); i++) { if (inputText.charAt(i) == ' ') { foundSpace = true; } else { if (foundSpace == true) { result += ' '; 1 2. 3. Take the code you developed in the last homework for problem 4 (the email address recognizer) and build a CFG for it. Using the test suite you developed for that assignment, generate reports for code coverage and for branch coverage for the tests you already submitted. Identify test cases necessary to reach 100% coverage. You may present these as spec’s or as actual test cases. Please characterize the gaps the structural tests identified in your testing regime and what you needed to add, if anything, to close these gaps. (50 points) Bonus (10 points) Extend the analysis in the previous problem (statement and branch coverage against the email address recognizer) to include condition coverage. Using the test suite you developed for that assignment, generate reports for condition coverage for the tests you already submitted. Identify test cases necessary to reach 100% coverage. You may present these as spec’s or as actual test cases. Please characterize the gaps the structural tests identified in your testing regime and what you needed to add, if anything, to close these gaps.

发表评论

电子邮件地址不会被公开。 必填项已用*标注