SWE 637 Homework 1
Fall 2006
Preliminary Concepts: Due 9/5, beginning of class


The true subject matter of the tester is not testing, but the design of test cases.

Answer the following questions. Bring hardcopies of your answers to class; either hand written or printouts. All homeworks are due before class on the due date. Please remember that the GMU Honor Code is in effect: Each student is expected to work alone and you may not share solutions or solution ideas.

Consider the following program:
     public class firsthwk
     {
     public static int nameCheck (char[] names)
     {
     // Effects: Checks a list of names and counts how many blanks
        int blankCount = 0;
        for (int i = names.length; i > 1; i--)
        {
           if (names[i-1] == ' ')
           {
              blankCount++;
           }
        }
        return blankCount;
     }

     public static void main (String args[])
     {
        // Test driver -- method calls to nameCheck()
     }
     }
  1. Compile this program using a Java compiler. You will need to modify the main() method to contain calls to the nameCheck() method and print the result. (Each call to the method represents one test case.) Submit a hard-copy printout of your complete program, with your main().
  2. This program contains a fault. What is it? Does executing the program necessarily result in either incorrect output or in failure?
  3. Find a test case that results in failure. Verify by executing this test case.
  4. Identify another test case that does not result in failure. Verify by executing this test case.
  5. Find tests to execute every statement in the method nameCheck(). Find the minimal set, that is, turn in a set of tests such that if any one test was removed, the remaining tests would no longer execute every statement.