Top Banner

of 24

STM-Problems-2003

Apr 08, 2018

Download

Documents

Manchari
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/7/2019 STM-Problems-2003

    1/24

    STM Practice Sessions

  • 8/7/2019 STM-Problems-2003

    2/24

    1. Boundary Value Analysis

    Question

    X Company has a following unique rules for selection of employees.

    The employee age should be >=18 and

  • 8/7/2019 STM-Problems-2003

    3/24

    Answer A

    Boundary Age Education Marks

    LB 18 16 61

    LB+1 19 17 62MV 35 20 75

    UB-1 55 24 88

    UB 56 25 89

    LB-1 17 15 60

    UB+1 57 26 90

  • 8/7/2019 STM-Problems-2003

    4/24

    Answer B

    No of tests casesBVA= 4(3)+1=13

    Robust BVA=6(3)+1=19

    Worst case BVA=5^3=125

    Robust worst case BVA=7^3=343

  • 8/7/2019 STM-Problems-2003

    5/24

    Answer C:Robust BVATest Case # Age Education Mark

    1 35 20 75

    2 18 20 75

    3 19 20 75

    4 55 20 75

    5 56 20 75

    6 17 20 75

    7 57 20 75

    8 35 16 75

    9 35 17 75

    10 35 24 75

    11 35 25 75

    12 35 15 7513 35 26 75

    14 35 20 61

    15 35 20 62

    16 35 20 88

    17 35 20 89

    18 35 20 60

    19 35 20 90

  • 8/7/2019 STM-Problems-2003

    6/24

    2. White Box testing- Graph

    Identify the cyclomatic complexity of the

    Graph

    Indentify Number of unique paths

  • 8/7/2019 STM-Problems-2003

    7/24

  • 8/7/2019 STM-Problems-2003

    8/24

    Answer:

    edges and node method

    e = 22, n = 15v = 22 -15 +2

    v = 9

    P1=1-2-4-6-7-8-9-11-13-14-15

    P2=1-2-3-6-7-8-9-11-13-14-15

    P3=1-2-5-6-7-8-9-11-13-14-15

    P4=1-2-5-2-4-6-7-8-9-11-13-14-15

    P5=1-2-4-6-7-2-4-6-7-8-9-11-13-14-15

    P6=1-2-4-6-7-8-9-11-13-14-9-11-13-14-15P7=1-2-4-6-7-8-9-10-13-14-15

    P8=1-2-4-6-7-8-9-10-12-13-14-15

    P9=1-2-4-6-7-8-9-10-12-9-11-13-14-15

  • 8/7/2019 STM-Problems-2003

    9/24

    3. White Box testing

    ReturnAverage() /* Design Test cases ..*/public static double ReturnAverage(int value[], int AS, int MIN, int MAX){

    /* Function: ReturnAverage Computes the average of all those numbers in the input arrayinthe positive range [MIN, MAX]. The maximum size of the array is AS. But, the arraysizecould be smaller than AS in which case the end of input is represented by -999. */

    int i, ti, tv, sum;double av;i = 0; ti = 0; tv = 0; sum = 0;while (ti < AS && value[i] != -999) {

    ti++;if (value[i] >= MIN && value[i] 0)

    av = (double)sum/tv;elseav = (double) -999;

    return (av);}

  • 8/7/2019 STM-Problems-2003

    10/24

    Decision Table- Exercise

    Company X sells merchandise to wholesale and retail outlets.

    Wholesale customers receive a two percent discount on allorders. The company also encourages both wholesale and

    retail customers to pay cash on delivery by offering a two

    percent discount for this method of payment. Another two

    percent discount is given on orders of 50 or more units. Each

    column represents a certain type of order.

  • 8/7/2019 STM-Problems-2003

    11/24

    Solution

  • 8/7/2019 STM-Problems-2003

    12/24

    Decision Table- 2

    Pizza name type Personal

    Price

    Medium

    Price

    Family

    price

    Zesty chicken Non veg 85 170 320

    Veg Supreme Veg 205 340 530

    Chicken italia Non Veg 205 340 530

    A pizza company has launched a new restaurant and developed a software

    to take care of their billing needs. Following are the menu they have in their

    restaurant

    The customers can be pure vegetarian, mixed (veg+non veg) consumer

    If the value of bill is more than Rs 500 in an order the customer is eligible

    for a free desert

    Customer can order 1 pizza in a bill, All prices includes taxes

    The software should give the bill value and whether the customer iseligible for free desert

  • 8/7/2019 STM-Problems-2003

    13/24

    Solution sample

    parameter values Number of Values 1 2 3

    customer type Veg,Mixed 2 veg veg veg

    Pizza order vsup,fchic,zchic 3 zchic zchic zchic

    sizepersonal,medium,fa

    mily 3 personal medium family

  • 8/7/2019 STM-Problems-2003

    14/24

    Variable x

    De

    f

    Us

    e

    1

    2

    3

    1: Input(x)

    2: Input(y)

    3: if x < 10 then4: y := y + 2

    5: else

    6: x:= x+1

    7: end if

    8: if y > 20 then9: y := y +1;

    10: end if

    11: Write(x,y)

    12: end

    4. Data Flow Testing- Design DU Table

  • 8/7/2019 STM-Problems-2003

    15/24

    Answer : DU table for x & y

    Variable x

    De

    f

    Us

    e

    1 1 3

    2 1 11

    3 6 11

    Variable y

    De

    f

    Us

    e

    1 2 8

    2 2 113 4 8

    4 4 11

    5 9 11

  • 8/7/2019 STM-Problems-2003

    16/24

    5. Data Flow Testing: Design DU table

    Variable: r0, r1, r2, r3, a[]

    1 void sort(int n, int a[])

    { int r0, r1, r2, r3;

    2 r3 = 0;

    3 r1 = 0 ;

    4 while (r1

  • 8/7/2019 STM-Problems-2003

    17/24

    Variable r0 Variable r3

    Def Use Def Use

    1 5 9 5 7 15

    2 5 14 6 11 15

    3 10 9

    4 10 14Variable r1 Variable r2

    Def Use Def Use

    7 3 4 21 6 8

    8 3 5 22 6 9

    9 3 6 23 6 10

    10 3 7 24 6 11

    11 3 13 25 6 12

    12 3 14 26 12 8

    13 3 16 27 12 914 16 4 28 12 10

    15 16 5 29 12 11

    16 16 6 30 12 12

    17 16 7 31 13 15

    18 16 13

    19 16 14

    20 16 16

    Variable a[] Variable n

    Def Use Def Use32 1 5 40 1 4

    33 1 9 41 1 8

    34 1 10

    35 1 13

    36 15 5

    37 15 9

    38 15 10

    39 15 13

    Answer

  • 8/7/2019 STM-Problems-2003

    18/24

    6. Exercise: Design Test cases for the following problem

    (Decision Table-Cause & Effect)

    Indian income tax department has changed the tax policy

    and released a new application for you to test

    Following are the business rules:No tax till 1,50,0000

    10 per cent for 150,000 to 300,000,

    20 per cent for 300,001 to 500,000 and

    30 per cent for above 500,001For women, the non taxable limit is Rs 1.80 lakh

    For senior citizens, non taxable limit is Rs 2.25 lakh.

  • 8/7/2019 STM-Problems-2003

    19/24

    Solution sample

    IS Male Y,N Y Y Y Y Y

    Senior

    Citizen Y,N Y Y Y Y Y

    SalaryRange 150K,180K,225K,300K,500K 150k 180k 225k 300k 500k

    20

    Expected

    result

    No tax

    10%

    20%

    30%

  • 8/7/2019 STM-Problems-2003

    20/24

    Special value testing?

    1.Experience really helps

    2.Frequently done by the customer or user

    3.Defies measurement

    4.Highly intuitive

    5.Seldom repeatable

    6.Often, very effective

    Advantages:

    1.Complex mathematical (or algorithmic) calculations

    2.Worst Case situations (similar to robustness)

    3.Problematic situations from past experience4.Second guess the likely implementation

  • 8/7/2019 STM-Problems-2003

    21/24

    Slice based Testing

    The idea of slices is to separate a program

    into components that have some useful

    meaning

  • 8/7/2019 STM-Problems-2003

    22/24

    Slice based testing

    Given a program P, and a program graph G(P)

    in which statements and statement fragments

    are numbered, and a set V of variables in P,

    the slice on the variable set V at statement

    fragment n, written S(V,n), is the set node

    numbers of all statement fragments in P prior

    to n that contribute to the values of variablesin V at statement fragment n

  • 8/7/2019 STM-Problems-2003

    23/24

    Number of Test Coverage Items

    low

    high

    Sophistication

    DU-Path

    DD-Path

    BasisPath

    Slice

  • 8/7/2019 STM-Problems-2003

    24/24

    Effor o den fy Tes Coverage Ite s

    o

    hgh

    ophstication

    -

    ath

    -

    ath

    asis

    Path

    ice