1 of 77

Module 2

A perspective On Testing

2 of 77

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.

3 of 77

Software Testing Life Cycle (SDLC)

4 of 77

1. Requirement Analysis

  • Quality Assurance team understand the requirement.
  • Test team study the requirement in testing point of view.
  • The QA team interact with the various stakeholders(clients, Technical leads, Business analysist etc).
  • Requirements are either functional or non functional.

5 of 77

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)

6 of 77

2. Test Planning

  1. It helps us to determine the effort needed to validate the application.
  2. It helps the people outside the team.
  3. Important aspects are documented.
  4. Mentions the different types of testing performed.

7 of 77

3. Test case Development

Guild lines to develop a good test cases.

  • Test cases should be simple.
  • Avoid the test cases repetition.
  • Do not assume.
  • Create a test cases with end user in mind.
  • Ensure 100 % coverage.
  • Test cases must be identifiable.
  • Implement the testing techniques.
  • Peer review.

8 of 77

4. Test environment setup

    • Set up of test server
    • Set up the Network
    • Test PC setup
    • Bug reporting
    • Creating test data

9 of 77

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.

10 of 77

6. Test closer

Test closer report consists of

      • Test summary report.
      • Identifier.
      • Comprehensive Assessment.
      • Summary of result.
      • Evaluation.
      • Summary of activity.
      • Approval.

11 of 77

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�

12 of 77

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

13 of 77

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.

14 of 77

Specified and Implemented behaviors

U

15 of 77

16 of 77

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.

17 of 77

Functional Testing

Inputs

Outputs

18 of 77

Advantages of Black Box Testing / Black Box Test cases

 

The tester does not need knowledge of any specific programming languages.

    • The test is done from the point of view of the user, not the designer.
    • Test cases can be designed as soon as the specifications are complete or in parallel with implementation.
    • Designer and the tester are independent of each other.
    • Test cases are independent of how the software is implemented, so if the implementation changes , the test cases are still useful.

 

19 of 77

Disadvantages of Black Box Testing/ Black Box Test cases

    • The test can be redundant if the software designer has already run a test case.
    • Significant redundancies may exists among test cases.
    • The test cases are difficult to design and compounded by the possibility of gaps of untested software.
    • Testing every possible input stream is unrealistic because it would take an inordinate amount of time; therefore, many program paths will go untested.

 

20 of 77

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.

21 of 77

Advantages of White Box Testing are mentioned below:

  • All the features and functionality within the application can be tested.

• Testing can be started at the very initial stage.

  • Tester does not need to wait for interface or GUI to be ready for testing.

• Can reduce to number of test cases to be executed during black box testing.

22 of 77

  • Helps in checking coding standards and optimizing code.
  • Extra code resulting in hidden defects can be removed.
  • Reason of failure can be known.
  • Identifying test data is easy because coding knowledge will be a known.

23 of 77

Disadvantages of White Box Testing

  • Tester should be highly skilled because should have the knowledge of coding, implementation.
  • Cost of tester is very high.
  • White Box testing is very complex.
  • It is not possible to look into each piece of code to find out hidden errors.

24 of 77

  • Test cases maintenance can be tough if the implementation changes very frequently.
  • Since White Box Testing it closely tied with the application being testing, tools to cater to every kind of implementation/platform may not be readily available.
  • Testing of larger system is not possible.

25 of 77

Levels of Testing

Levels of abstraction and testing in the waterfall model.

26 of 77

The Triangle Problem

The triangle program is the most widely used example in software.

Problem Statement

  • Simple version: The triangle program accepts three integers, a, b, and c, as input. These are taken to be sides of a triangle. The output of the program is the type of triangle determined by the three sides: Equilateral, Isosceles, Scalene, or Not a Triangle.

27 of 77

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.

28 of 77

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.

29 of 77

30 of 77

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).

31 of 77

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

32 of 77

If a = c

Then match = match + 2

Endif

If b = c

Then match = match + 3

EndIf

33 of 77

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

34 of 77

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

35 of 77

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

36 of 77

Flowchart for the Traditional Triangle Problem Implementation

37 of 77

38 of 77

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

39 of 77

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

40 of 77

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)

41 of 77

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

42 of 77

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

43 of 77

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

44 of 77

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

45 of 77

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

46 of 77

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

47 of 77

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

48 of 77

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

49 of 77

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)

50 of 77

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

51 of 77

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

52 of 77

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

53 of 77

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

54 of 77

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

55 of 77

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

56 of 77

EndIf

EndIf

EndIf

EndCase

Output (“Tomorrow’s date is “, tomorrowMonth, tomorrowDay, tomorrowYear)

End NextDate2

57 of 77

The Commission Problem

  • A rifle salesperson in the former Arizona Territory sold rifle locks, stocks and barrels made by a gunsmith in Missouri, Locks cost $45, stocks cost $30, and barrels cost $25.
  • The salesperson had to sell at least one complete rifle per month, and production limits were such that the most the salesperson could sell in month was 70 locks, 80 stocks, and 90 barrels.
  • After each town visit, the salesperson sent a telegram to the Missouri gunsmith with the number of locks, stocks, and barrels sold in that town.

58 of 77

  • At the end of a month, the salesperson sent a very short telegram showing – 1 lock sold. The gunsmith then knew the sales for the month were complete and computed the salesperson’s commission as follows ” 10% on sales up to (and including) $1000, 15% on the next $800, and 20% on any sales in excess of $1800.

  • The commission program produced a monthly sales report that gave the total number of locks, stocks, and barrels sold by the salesperson’s, total dollar sales, and finally, the commission.

59 of 77

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

60 of 77

Lockprice = 45.0

Stockprice = 30.0

barrelPrice = 25.0

totalLocks = 0

totalStocks = 0

totalBarrels = 0

61 of 77

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

62 of 77

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)

63 of 77

If (sales > 1800.0)

Then

Commission = 0.10 * 1000.0

Commission = commission + 0.15 * 800.0

Commission = commission + 0.20 * (sales-1800.0)

64 of 77

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

65 of 77

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.

66 of 77

SATM TERMINAL

67 of 77

68 of 77

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.

69 of 77

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.

70 of 77

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.

71 of 77

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.

72 of 77

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.

73 of 77

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.

74 of 77

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.

75 of 77

76 of 77

��Saturn Windshield wiper controller ��• �

  • The windshield wiper on some Saturn automobiles is controlled by a lever with a dial.
  • The lever have four positions – OFF, INT (for intermittent), LOW, and HIGH
  • The dial has three positions 1, 2, and 3.
  • The dial position indicates three intermittent speeds, and the dial position is relevant only when the lever is at INT position

77 of 77