Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

Explain three ways that sales employees are typically compensated.

Answered: 1 week ago