Question: Question 2: In this question, you will apply the state transition testing technique discussed in class. You are given the state transition graph (see below)

Question 2:

In this question, you will apply the state transition testing technique discussed in class. You are given the state transition graph (see below) modeling the lifecycle of a case in a certain application. Your task is to define three sets of test cases: the first one covers (exercises) all states, the second one covers all transitions, and the third one covers all simple paths (i.e., paths with no cycles) [only include paths of length 3 where the length of the path is the total number of edges in the page].

You must test the provided program by executing the test cases. For example, the output of the following command:

java Q2 close open close

is

Closed

It is assumed that the initial state is Opened. The events are: open, close, lock, and unlock. The states are: Opened, Closed, and Locked. The string inputs are case-sensitive.

Assume that the inputs are of the correct type. Also, assume that the user always types in the correct strings i.e., there is no misspelling of the event names.

For each test case, identify the covered states and transitions. Also, indicate whether the corresponding test passes or fails. List the test cases of the three sets separately.

For example, the test case corresponding the above entered command visits the states {Opened, Closed} and transitions {close, open}

use this code

public class Q2 { static int[][] SM; public static void main(final String[] args) { String s = "Opened"; for (int i = 0; i < args.length; ++i) { s = stateSTRING(Q2.SM[stateINT(s)][trans(args[i])]); } System.out.println(s); } public static int trans(final String t) { switch (t) { case "close": { return 0; } case "open": { return 1; } case "lock": { return 2; } case "unlock": { return 3; } default: { return -1; } } } public static int stateINT(final String s) { switch (s) { case "Opened": { return 0; } case "Closed": { return 1; } case "Locked": { return 2; } default: { return -1; } } } public static String stateSTRING(final int s) { switch (s) { case 0: { return "Opened"; } case 1: { return "Closed"; } case 2: { return "Locked"; } default: { return ""; } } } static { Q2.SM = new int[][] { { 1, 0, 0, 0 }, { 1, 0, 2, 1 }, { 2, 2, 2, 1 } }; } }

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!