Module 2
A perspective On Testing
Software Testing Life Cycle(STLC)�� STLC identifies what test activities to carry out and when to accomplish those test activities. Even though testing differs between organizations, there is a testing life cycle.
Software Testing Life Cycle (SDLC)
1. Requirement Analysis
Types of requirements
1. Business requirements. (High level requirements)
2. Architectural requirements. (more detailed requirement)
3. System and integration requirement. (Low level and detailed description)
2. Test Planning
3. Test case Development
Guild lines to develop a good test cases.
4. Test environment setup
5. Test Execution
Test team starts executing the test cases based on prepared test planning.
If any test case is failed, then corresponding defect can be reported to developer team via bug tracking system.
6. Test closer
Test closer report consists of
Test Cases �� Aim of testing is to determine a set of test cases. �Inputs: Pre-conditions (circumstances that hold prior to test case execution), Actual Inputs identified by some testing method.�Expected Outputs: Post- conditions and actual outputs�
Typical Test Case Information (Contents of a Test Case)�Title, author, date, �Test case ID
Purpose�Pre-conditions�Inputs�Expected Outputs �Observed Outputs� Pass/Fail �Comments
Insight from the Venn Diagram�
A Venn diagram is made up of two or more overlapping circles. It is often used in mathematics to show relationships between sets.
In software testing, Venn Diagrams are used to represent input/output relationships for the system.
Specified and Implemented behaviors�
U
Identifying test cases�
Two fundamental approaches are used to identify test cases, Known as Functional and Structural testing. Each of these has different test case identification methods, referred to as testing methods.
Functional Testing�
Inputs
Outputs
Advantages of Black Box Testing / Black Box Test cases
The tester does not need knowledge of any specific programming languages.
Disadvantages of Black Box Testing/ Black Box Test cases�
Structural Testing�
Structural Testing is the other approach to test case identification. It is also called as White Box, Clear Box, Glass box, Open box testing.
Advantages of White Box Testing are mentioned below:
• Testing can be started at the very initial stage.
• Can reduce to number of test cases to be executed during black box testing.
Disadvantages of White Box Testing
�Levels of Testing �
Levels of abstraction and testing in the waterfall model.
�The Triangle Problem �
The triangle program is the most widely used example in software.
Problem Statement
Improved version: The triangle program accepts three integers a, b and c must satisfy the following conditions:
c1. 1 <= a <= 200 c4. a < b + c
c2. 1 <= b <= 200 c5. b < c + a
c3. 1 <= c <= 200 c6. c < a + b
The output of the program is the type of triangle determined by the three sides: Equilateral, Isosceles, scalene or Not A Triangle.
If values of a, b, and c satisfy conditions c1, c2, and c3, one of four exclusive outputs is given:
1. If all three sides are equal, the program output is Equilateral.
2. If exactly one pair of sides is equal, the program output is Isosceles.
3. If no pair of sides is equal, the program output is Scalene.
4. If any of conditions c4, c5 and c6 is not met, the program output is Not A Triangle.
Triangle program contains clear but complex logic. The specification insists developers to know some details about triangles, its inequality i.e., sum of two sides must be greater than the third side. (preconditions).
Traditional Implementation
Dim a, b, c, match As INTEGER
Output (“Enter 3 integers which are sides of a triangle”)
Input (a, b, c)
Output (“Sides A, B, C are”, a, b, c)
Match = 0
If a = b
Then match = match + 1
EndIf
If a = c
Then match = match + 2
Endif
If b = c
Then match = match + 3
EndIf
If match = 0
Then If (a + b) <= c
Then output (“NotATriangle”)
Else If (b + c) <=a
Then Output (“NotATriangle”)
Else If (a + c) <=b
Then Output (“NotATriangle”)
Else Output (“Scalene”)
EndIf
EndIf
EndIf
Else If match=1
Then If (a + b) <=c
Then Ouput (“NotATriangle”)
Else Ouput (“Isosceles”)
EndIf
Else if match=2
Then If (a + c) <=b
Then Ouput (“NotATriangle”)
Else Ouput (“Isosceles”)
EndIf
Else If match=3
Then If (b + c) <=a
Then Output (“NotATriangle”)
Else Ouput (“Isosceles”)
EndIf
Else Output (“Equilateral”)
EndIf
EndIf
EndIf
EndIf
End Triangle1
Flowchart for the Traditional Triangle Problem Implementation
Program triangle2 ‘programming version of simpler specification
Dim a ,b, c As INTEGER
Dim IsATriangle As Boolean
Step1 : Get Input
Output (“Enter 3 integers which are sides of a triangle”)
Input(a ,b ,c)
Output (“Sides A, B, C are”, a ,b ,c)
Step2 : Is A Triangle ?
If (a < b + c) AND (b < a + c) AND (c < a + b) Then
IsATriangle = True
Else IsATriangle = False
EndIf
Step3 : Determine Triangle Type If IsATriangle
Then If (a = b) AND (b = c) AND (a=c)
Then Output (“Equilateral”)
Else If (a ≠ b) AND (a ≠ c) AND ( b ≠ c)
Then Output (“Scalene”)
Else
Output (“Isosceles”)
EndIf
EndIf
Else Output (“Not a Triangle”)
EndIf
End triangle2
Program triangle3 ‘ structured programming version of improved specification
Dim a ,b ,c As integer
Dim c1, c2, c3, IsATriangle As Boolean
Step 1 : Get Input
Do
Output (“Enter 3 integers which are sides of a triangle”)
Input (a ,b, c)
C1 = (1 <= a) AND (a <= 200)
C2 = (1 <= b) AND (b <= 200)
C3 = (1 <= c) AND (c <= 200)
If NOT(c1)
Then Output (“Value of a is not in the range of permitted values”)
EndIf
If NOT(c2)
Then Output (“Value of b is not in the range of permitted values”)
EndIf
If NOT(c3)
Then Output (“Value of c is not in the range of permitted values”)
EndIf
Until c1 AND c2 AND c3
Output (“Sides A, B, C are” ,a ,b ,c)
Step 2 : Is A triangle?
If (a < (b + c)) AND (b < (a + c)) AND (c < (a + b))
Then IsATriangle = True
Else IsATriangle = False
EndIf
Step 3 : Determine Triangle Type
If IsATriangle
Then If (a = b) AND (b = c)
Then Output (“Equilateral”)
Else If (a ≠ b) AND (a ≠ c) AND (b ≠ c)
Then Output (“Scalene”)
Else Output (“Isosceles”)
EndIf
EndIf
Else Output (“Not a Triangle”)
EndIf
End Triangle3
NextDate Function Implementation
Dim tomorrowDay, tomorrowMonth, tomorrowYear As Integer
Dim day, month, year As Integer
Output (“Enter today’s date in the form MM DD YYYY”)
Input (month, day, year)
Case 1 : month Is 1,3,5,7,8, or 10 : ‘31 day months (except Dec.)
If day < 31
Then tomorrowDay = day +1
Else
tomorrowDay = 1
tomorrowMonth = month + 1
EndIf
Case 2 : month Is 4,6,9, or 11 ‘30 day months
If day < 30
Then tomorrowDay = day +1
Else
tomorrowDay = 1
tomorrowMonth = month + 1
EndIf
Case 3 : month Is 12 :
If day < 31
Then tomorrowDay = day + 1
Else
tomorrowDay = 1
tomorrowMonth = 1
If year = 2012
Then Output (“2012 is over”)
Else tomorrow.year = year + 1
EndIf
EndIf
Case 4: month is 2 : ‘February
If day < 28
Then tomorrowDay = day +1
Else
If day = 28
Then
If (year is a leap year)
Then tomorrowDay = 29 ‘ leap year
Else //not a leap year
tomorrowDay = 1
tomorrowMonth = 3
EndIf
Else If day = 29
Then tomorrowDay = 1
tomorrowMonth = 3
Else Output (“cannot have Feb.”, day)
EndIf
EndIf
EndIf
EndCase
Output (“Tomorrow’s date is “, tomorrowMonth, tomorrowDay, tomorrowYear)
End NextDate
Program Nextdate2 ‘ Improved version
Dim tomorrowDay, tomorrowMonth, tomorrowYear As Integer
Dim day, month, year As Integer
Dim c1, c2, c3 As Boolean
Do
Output (“Enter today’s date in the form MM DD YYYY”)
Input (month, day, year)
C1 = (1 <= day) AND (day <= 31)
C2 = (1 <= month) AND (month <=12)
C3 = (1812 <= year) AND (year <=2012)
If NOT (c1)
Then Output (“Value of day not in the range 1...31”)
EndIf
If NOT (c2)
Then Output (“Value of month not in the range 1..12”)
EndIf
If NOT (c3)
Then Output (“Value of year not in the range 1812...2012”)
EndIf
Until c1 AND c2 AND c3
Case month of
Case 1 : month Is 1,3,5,7,8, or 10: ‘31 day months (except Dec..)
If day < 31
Then tomorrowDay = day +1
Else
tomorrowDay = 1
tomorrowMonth = month + 1
EndIf
Case 2 : month Is 4,6,9, or 11 ‘30 day months
If day < 30
Then tomorrowDay = day +1
Else
If day = 30
Then tomorrowDay = 1
tomorrowMonth = month + 1
Else Output (“Invalid Input Date”)
EndIf
EndIf
Case 3 : month Is 12 : ‘December
If day < 31
Then tomorrowDay = day + 1
Else
tomorrowDay = 1
tomorrowMonth = 1
If year = 2012
Then Output (“Invalid Input Date”)
Else tomorrow.year = year + 1
EndIf
EndIf
Case 4: month is 2 : ‘February
If day < 28
Then tomorrowDay = day +1
Else
If day = 28
Then
If (year is a leap year)
Then tomorrowDay = 29 ‘leap year
Else //not a leap year
tomorrowDay = 1
tomorrowMonth = 3
EndIf
Else
If day = 29
Then
If (year is a leap year)
Then tomorrowDay = 1
tomorrowMonth = 3
Else
If day > 29
Then Output (“Invalid Input Date”)
EndIf
EndIf
EndIf
EndIf
EndIf
EndCase
Output (“Tomorrow’s date is “, tomorrowMonth, tomorrowDay, tomorrowYear)
End NextDate2
The Commission Problem
Commission Problem
Program Commission (INPUT, OUTPUT)
Dim locks, stocks, barrels As Integer
Dim lockprice, stockprice, barrelprice As Real
Dim totalLocks, totalStocks,totalBarrels as Integer
Dim lockSales, stockSales, barrelSales As Real
Dim sales, commission : REAL
Lockprice = 45.0
Stockprice = 30.0
barrelPrice = 25.0
totalLocks = 0
totalStocks = 0
totalBarrels = 0
Input (locks)
While NOT (locks = -1) //Input device uses -1 to indicate end of data entry
Input (stocks, barrels)
totalLocks = totalLocks + locks
totalStocks = totalStocks + stocks
totalBarrels = totalBarrels + barrels
Input (locks)
EndWhile
Output (“Locks sold : “, totalLocks)
Output (“Stocks sold : “, totalStocks)
Output (“Barrels sold : “, totalBarrels)
lockSales = lockPrice * totalLocks
stockSales = stockPrice * totalStocks
barrelSales = barrelPrice * totalBarrels
sales = lockSales + stockSales + barrelSales
Output (“total sales : “, sales)
If (sales > 1800.0)
Then
Commission = 0.10 * 1000.0
Commission = commission + 0.15 * 800.0
Commission = commission + 0.20 * (sales-1800.0)
Else If (sales > 1000.0)
Then
Commission = 0.10 * 1000.0
Commission = commission + 0.15 * (sales – 1000.0)
Else commission =0.10 * sales
EndIf
EndIf
Output (“commission is $ “, commission)
‘End commission
The SATM System
The SATM system communicates with bank customers via the 15 screens using a terminal with features. SATM customers can select any of three transaction types: deposits, withdrawals and balance inquiries. This transaction can be done on two types of accounts: checking and savings.
SATM TERMINAL
When a bank customer arrives at an SATM station, screen 1 is displayed.
The bank customer accesses the SATM system with a plastic card encoded with a personal account number (PAN) which is key to an internal customer account file.
If the customer’s PAN matches the information in the customer account file, the system presents screen 2 to the customer.
If the customer’s PAN is not found, screen 4 is displayed, and the card is kept.
At screen 2 the customer is prompted to enter Personal Identification Number (PIN).
If the PIN is correct, the system displays screen 5; otherwise, screen 3 is displayed. The customer has three chances to get the PIN correct; after three failures screen 4 displayed, and the card is kept.
On entry to screen 5, the system adds two pieces of information to the customer’s account file: the current date and an increment to the number of ATM sessions.
The customer selects the desired transactions from the options shown on screen 5; then the system immediately displays screen 6,where the customer chooses the account to which the selected transaction will be applied.
If balance is requested, the system checks the local ATM file for any unposted transactions and reconciles these with the beginning balance for that day from the customer account file. Screen 14 is then displayed.
If a deposit is requested, the status of the deposit envelope slot is determined from a field in the terminal control file. If no problem is known, the system displayed screen 7 to get the transaction amount. If a problem occurs with the deposit envelope slot, the system displays screen 12.
Once the deposit amount has been entered, the displays screen 13, accepts the deposit envelope, and the processes the deposit.
The deposit amount is entered as an unposted amount in the local ATM file, and the count of deposits per month is incremented. Both of these are processed by the master ATM (centralized) system once a day. The system then displays screen 14.
If a withdrawal is requested, the system checks the status (jammed or free) of the withdrawal chute in the terminal control file. If jammed, screen10 is displayed; otherwise, screen 7 is displayed so the customer can enter the withdrawal amount.
Now, the system checks the terminal status file to see if it has enough money to dispense. If it does not, screen 9 is displayed; otherwise, the withdrawal is processed. The system checks the customer balance, if the funds are insufficient, screen 8 is displayed. If the account balance sufficient, screen 11 is displayed and the money is dispensed.
The withdrawal amount is written to the unposted local ATM file, and the count of withdrawals per month is incremented. The balance is printed on the transaction receipt as it is for a balance request transaction. After the cash has been removed, the system displays screen14.
When the “No” button is pressed in screen 10, 12, or 14, the system presents screen 15 and returns the customer’s ATM card. Once the card is removed from the slot, screen 1 is displayed. When the “yes” button is pressed in screen 10, 12, or 14, the system presents screen 5 so the customer can select additional transactions.
The Currency Converter
The application converts U.S. dollars to any of the four currencies: Brazilian reals, Canadian dollars, European Union Euros, and Japanese yen.
• Currency selection is governed by the radio buttons, which are mutually exclusive.
• When a country is selected, the systems respond by completing the label.
for example, “Equivalent in…” becomes “Equivalent in Canadian dollars” if the Canada button is clicked.
��Saturn Windshield wiper controller ��• �