POTD 8: Program mutation (sum)

Due 8-Nov-2025, 11am EST
Purpose: Understand and apply mutation testing concept to program source code; get ready to work on homework assignment, and prepare for quiz 5 and the final exam.

You may make a copy of a worksheet and complete this activity, or simply type your answers in any text editor.

You may work alone or with at most two other students in this course (feel free to make use of any communication channels of your choice).


Consider the sum method

/**
 * Sum values in an array
 *
 * @param x array to sum
 * @return sum of values in x
 * @throws NullPointerException if x is null
 */
line 1:   public static int sum(int[] x)
line 2:   {
line 3:      int s = 0;
line 4:      for (int i=0; i < x.length; i++) 
line 5:      {
line 6:         // s = s + x[i];        // original
line 6':        s = s - x[i];           // AOR mutant
line 7:      }
line 8:      return s;
line 9:   }   

Mutation operator: AOR (Arithmetic Operator Replacement)  replaces each occurrence of +, -, *, /, **, and % by each of the other operators.

For this activity, you only need to consider the given AOR mutant (line 6').

  1. If possible, find test case inputs that do not reach the mutant.
    If x is null or an empty array, then the mutant is never reached. 
        
    Test case value: x=[]
         Result from running the test    Original: s=0
                                         Mutant:   s=0   
  2. If possible, find test inputs that satisfy reachability but not infection for the mutant.
    Any input with all zeroes will reach but not infect. 
    
    Test case value: x=[0,0]
         Result from running the test    Original: s=0
                                         Mutant:   s=0   
  3. If possible, find test inputs that weakly kill the mutant.
    Any input with nonzero entries, but with a sum of zero, is fine. 
    
    Test case value: x=[1,-3,2] 
         Result from running the test    Original: s=0
                                         Mutant:   s=0   
  4. If possible, find test inputs that strongly kill the mutant.
    Any input with a nonzero sum works.  
    
    Test case value: x=[1,2,3] 
         Result from running the test    Original: s=6
                                         Mutant:   s=-6   


Grading rubric

[Total: 10 points]: Done (or provide evidence of your attempt, full or reasonable effort)

(-2.5 points) for 24 hours late (submitted after 8-Nov-2025 11am EST, by 9-Nov-2025 11am EST)
(-5 points) for 48 hours late (submitted after 9-Nov-2025 11am EST, by 10-Nov-2025 11am EST)


Submission

Making your submission available to instructor and course staff is your responsibility; if we cannot access or open your file, you will not get credit. Be sure to test access to your file before the due date.


Copyright © 2025 Upsorn Praphamontripong
Released under the Creative Commons License CC-BY-NC-SA 4.0 license.
Last updated 2025-11-02 10:28