Question: 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

 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);

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; Ao = null; Impossible nothing = new Impossible(); if (i == 0) q = 4; q++; switch (arg.length()) { case 0: 0/= 2; break; case 1: 0 = 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 path coverage. 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 3 (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. 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; Ao = null; Impossible nothing = new Impossible(); if (i == 0) q = 4; q++; switch (arg.length()) { case 0: 0/= 2; break; case 1: 0 = 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 path coverage. 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 3 (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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!