Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please develop Junit tests for at least 3 of the methods in class ArrayOperations. Try to reach 1 0 0 % statement coverage and 1
Please develop Junit tests for at least of the methods in class ArrayOperations. Try to reach statement coverage and branch coverage. package inclass; public class ArrayOperations Adapted from "Introduction to Software Testing", by Ammann and Offutt public static int numZeroint x Effects: if x null throw NullPointerException else return the number of occurrences of in x int count ; for int i; i; i if xi y return i; return ; test: x ; y ; expected public static int countPositive int x if x null throw new NullPointerException; int count ; for int i; i count; return count; test: x expected public static int lastZero int x if x null throw new NullPointerException; for int i; i count; return count; test: x expected
Please develop Junit tests for at least of the methods in class ArrayOperations. Try to reach statement coverage and branch coverage.
package inclass;
public class ArrayOperations
Adapted from "Introduction to Software Testing",
by Ammann and Offutt
public static int numZeroint x
Effects: if x null throw NullPointerException
else return the number of occurrences of in x
int count ;
for int i; i; i
if xi y
return i;
return ;
test: x ; y ;
expected
public static int countPositive int x
if x null
throw new NullPointerException;
int count ;
for int i; i
count;
return count;
test: x
expected
public static int lastZero int x
if x null
throw new NullPointerException;
for int i; i
count;
return count;
test: x
expected
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started