After gathering business requirements and transitioning them each into a format that looks like a pseudo-code, we have to extract test scenarios from each pseudo-code. A test scenario outlines a condition that needs to be tested. A test case is an element of a test scenario that specifies values used in the test. For example, in the business event A product arrives from a supplier, one test scenario could be a product arrives from an offshore supplier and another could be a product arrives from a domestic supplier.
Under the first test scenario, you might have the following test cases:
Test Case #1:
Offshore supplier: ABS Enterprise Ltd
PO: ABS-1199
Product: 200-AAA
Quantity: 100 cases
Test Case #2:
Offshore supplier: ABS Enterprise Ltd
PO: ABS-1300
Product: 333-CCC
Quantity: 1000 units
Product 200-AAA
Quantity: 500 cases
There can be many, many test cases for a given test scenario. Similarly, there can be many test scenarios for a given use case, and there can be many use cases for a business event. Figure 10-1 gives a basic schematic of the relationship between business events, use cases, test scenarios, and test cases.
FIGURE 10-1: Business Event, Use Cases, Test Scenarios, and Test Cases
How can we write test scenarios based on a use case? Let’s return to the banking use case described in Chapter 9 and reprinted here as Table 10-1:
TABLE 10-1: Use Case for a Customer Making a Deposit
Event name | A customer makes a deposit |
Use case name | Receive customer deposit at the bank counter |
Unique use case ID | UC 1.1 |
Goal | |
Actor(s) | Customer, teller, system |
Brief description | Customer makes an in-person deposit at the bank through the bank teller. |
Precondition | The teller is logged into the system and is authorized to perform the function of accepting a deposit from a customer. |
Trigger | Customer tells the teller that he or she wants to make a deposit to his or her account. |
Main (ideal) flow |
6. Teller issues a deposit receipt to the customer. The receipt includes the following:
|
Post-condition success | Account balance is updated with the new deposit. The system generates a receipt. |
Alternate flow/exception flow |
4. Account does not exist. 4.i. System displays an error message. (You may be able to describe at this point what the actual message should be.) 4.ii. Teller notifies customer that the account is not a recognized account. 6. Account is inactive. 6.i System displays an error message. 6.ii. Teller notifies customer that the account is inactive. |
Post-condition failure | Deposit is not accepted into the account provided by the customer. |
Assumption | There is a GUI for the interaction between the teller and the system that will allow the teller to enter all the information given by the customer when he or she makes a deposit. |
Issues | — |
We have three test scenarios: the main (ideal) flow, exception flow 4 (account does not exist), and exception flow 6 (account is inactive). The number of test cases depends on how many variations of data combinations the business encounters. For example, how many variations of account numbers are there? How many account types are there?
For the banking scenario above, we can build a spreadsheet to show all the possible data combinations to be tested (Figure 10-2). This requires real patience—there could be many, many data combinations.
TABLE 10-2: Retail Banking Test Data Spreadsheet
Let’s take a look at how to write test scripts from use cases. The contents of the example test specification document shown in Table 10-3, below, are extracted from the use case shown in Table 10-1.
Business process | UC 1.1 |
Module | Main flow |
Function | Receive customer deposit (at bank counter) |
Cycle | System test |
Prerequisite | Test 1.0 |
Test scenario | 1.1 |
Test data | 1 |
Prepared by | John Smith |
Date | 06/20/2008 |
Test objective | Validate the ability to receive customer deposit at the bank counter |
TABLE 10-3: Retail Banking Test Specification Document
If the test result is not as expected and is not acceptable, a test problem report must be completed. Table 10-4 is an example:
TABLE 10-4: Example Test Problem Report
Writing test scripts from use cases is an almost mechanical process. Follow each step identified in the use case, and you have the makings of all the scenarios you need to test. The challenge is in identifying every possible combination of data that should be tested and defining the expected results for each case.
3.147.67.195