Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3 . ( 5 0 points ) Consider the following program: class M { public static void main ( String [ ] argv ) {

3.(50 points) Consider the following program:
class M {
public static void main(String [] argv){
M obj = new M();
if (argv.length >0)
obj.m(argv[0], argv.length); }
public void m(String arg, int i){
int q =1;
A o = null;
Impossible nothing = new Impossible();
if (i ==0) q =4; q++; switch (arg.length()){
case 0: q /=2; break;
case 1: o = new A(); new B(); q =25; break;
case 2: o = new A(); q = q *100; // no break
default: o = new B(); break; }
if (arg.length()>0){ o.m();
} else {
System.out.println("zero");
}
nothing.happened();
}
}
class A {
public void m(){
System.out.println("a");
}
}
class B extends A {
public void m(){ System.out.println("b");
}
}
class Impossible{
public void happened(){
//"2b||!2b?", whatever the answer nothing happens here
}
}
a) Using the minimal number of nodes (hint: 11), draw a Control Flow Graph (CFG) for method
M.m() and include it in your submission. The CFG should be at the level of basic blocks. See the lecture slides on CFG for examples.
(b) List the sets of Test Requirements (TRs) with respect to the CFG you drew in part (a) for each of the following coverages: node coverage; edge coverage; edge-pair coverage; and prime path3coverage. In other words, write four sets: TRNC , TREC , TREPC , and TRPPC . If there are infeasible test requirements, list them separately and explain why they are infeasible.
(c) Create test sets for method M.m() that achieve each of the following coverages: (1) node
coverage but not edge coverage; (2) edge coverage but not edge-pair coverage; (3) edge-pair
coverage but not prime path coverage; and (4) prime path coverage. In other words, you will
write four test sets (groups of test cases) in total. One test set satisfies (1), one satisfies (2), one
satisfies (3), and the last satisfies (4), if possible. If it is not possible to write a test set to satisfy
(1),(2),(3), or (4), explain why. For each test case written, explain which TRs are satisfied by
that test. Consider feasible test requirements only for this part.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Determine the median for the numbers inProblem. 6. 2 4 3 3 5 4,

Answered: 1 week ago

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago