Starting from:

$30

Software Testing Assignment 1 -Solved


Below is one faulty program. It includes test inputs that result in failure. Answer the following 
questions about this program. 
Program: 
public int findLast (int[] x, int y) { 
// Effects: if x==null throw NullPointerException 
// else return the index of the last element in x that equals y 
// If no such element exists, return -1 
for (int i =x.lenght-1; i > 0; i--) 

if (x[i] == y) 

return i; 


return -1; 

// test x=[2,3,5] y=2 
// expected output =0 
a) Explain what is wrong with the given code. Describe the fault precisely by proposing a 
modification to the code. 
b) If possible, give a test case that does not execute the fault. If not, briefly explain why not. 
c) If possible, give a test case that executes the fault, but does not result in an error state. If not, 
briefly explain why not. 
d) If possible give a test case that results in an error, but not a failure. If not, briefly explain why 
not. Hint: Don’t forget about the program counter. 
e) For the given test case, describe the first error state. Be sure to describe the complete state 

Objectives 
• Studying implementation of an open source project. 
• Using Input space-partitioning & boundary-analysis techniques to design test cases. 
• Learn unit testing and code coverage. Software Testing – Winter 2021 
Description 
• In this task, you will study the open source code of "java-math-library". 
• There is no JavaDoc for this code, but the code is commented in the same style, so you 
should read carefully and try to grasp as much as you can. Furthermore, you may refer to 
the JavaDocs of the parent classes from the Java SDK. 
• You are to study the following classes (de.tilman_neumann.util.StringUtil and 
de.tilman_neumann.util. Multiset_HashMapImpl) 
• Once you study those APIs implementations/documentations, you are required to use 
input space partitioning along with boundary values analysis to design unit tests for their 
methods. 
Tas

More products