Equivalence Classes (EC) : Two or more test cases are equivalent if they all test the same thing. If one of them can not detect a given type of defect, others too can not detect the same. If one of them can detect a given type of defect, others too can detect the same.
Equivalence Partitioning (EP) comprises selecting one test-case from each equivalence class. If you expect the same/similar result from two tests, use only one of them.
Purpose : Filter out redundant test-cases. Select effective test-cases from a huge set of possibilities. To save time and labour, minimise number of test cases, but maximise coverage.
Illustrative example : Tabulated below are rows of data. Each row has 4 columns. Domain of each column is first given, followed by sets of equivalent test-data rows. One out of each set is sufficient for testing.
From the tabulation, it would be seen that EP basically comprises partitioning the input domain of a program into a finite number of equivalence classes such that testing one representative row of test-data of one equivalence class is same as testing with all the rows of test-data of that equivalence class. If through trial and error it is found that different rows of an equivalence class are treated differently by the target under test, sub-divide the equivalence class till all rows per equivalence class are practically equivalent.
Check for boundary values. For example, for months = 1 to 12 (Jan. to Dec.), check for boundary values - 1 and 12 ; and for values just beyond the boundaries – 0 and 13. Also check for null.
Similarly for weekdays = 1 to 7 (Mon. to Sun.), check for 1, 7, 0, 8 and Null.
Boundary checks are also illustrated below for rows with 4 columns as under :
In general, a state machine is any device that (a)has an initial status, (b)changes and stores status on application of an input, and/or (c)cause an action or output.
ú A computer itself is basically a state machine and each machine instruction is input that changes one or more states and may cause other actions to take place. Each computer's data register stores a state. The ROM from which a boot program is loaded stores a state. The boot program itself is an initial state. The operating system is itself a state and each application that runs begins with some initial state that may change as it begins to handle input. Thus, at any moment in time, a computer system can be seen as a very complex set of states and each program in it as a state machine.
ú ATM : Automated Teller Machine.
ú A vending machine.
A state machine can be described as:
For the purpose of testing, where relevant, state table comprising possible inputs, corresponding states and expected actions/outputs can be tabulated.
ATM, Black-box Testing and State Machine : In respect of an ATM, starting from initial state, each user action – inserting card, typing in PIN, pressing keys for various options, to exit – and can be mapped to corresponding ATM state, and appropriate action like displaying a message, showing balance, dispensing cash, printing ATM slip, etc. Tabulation of alternate logical sequences of inputs, the corresponding states, and the expected ATM actions/outputs is the most appropriate way to guide the testing process.
Program Code, White-box Testing and State Machine : Examine if a program with many flags/flag-variables and/or deeply nested if-then-else or choose-case statements can be mapped to a state machine for testing purpose.
Program Design and State Machine and its Testing : Mapping activities in modules like "Order-Processing" to a State Machine make for clearer design, parameterised and maintainable code, testable requirements and testable design and code. For example, web-based books ordering system would involve, inter alia, selection of books, display of total cost, confirmation, options to pay by credit cards, etc. The stages/states can be better handled and captured and flexibly coded using a database table.
Processing, EoD = End-Day Processing.