Pairwise example in practice

Challenge:

Testing part of application that helps people to set medical appointments. Apart from appointments in proper facility people may get advice by phone, home-visit or get general advice for certain group of symptoms.

Task:

Creation of Test suite that will cover all paths for indicated system.

Steps required to achieve the goal and conclusions:

  1. Analyze input data.

    After deep analysis of possible input values, data set was limited to the values that provide various path coverages for tested application. Values were chosen to be the best representatives of data that interacts with each other, and to discover defects that may have critical impact on the tested system.

  2. Provide data for AnkrPt Pairwise and combinatorial testing.

    We created input categories with indicated positive values:

    CRITERIA NAME     VALUES
    Person       child,	adult,	child under 2,
    MD           pediatrician,	internist,	dermatologist,
    Purpose      control check,	prescription,	infection,
    Symptoms     fever, 	rash & fever,	rash,	runny nose,
    Visit Type   phone,	home-visit,	emergency,

    Assumptions:

    For provided data we expect to have full coverage of the system. We can try testing all combinations of given values (getting 324 test cases = 3*3*4*3*3 - Cartesian Count) or try to use a shortcut to achieve it with Pairwise, making test case numbers significantly less.

    Observations:

    Pairwise by AnkrPt generates a Test Suite for this input data set containing 16 test cases, that are composed of 102 simple all-pairs of given values:

    # Person MD Purpose Symptoms Visit Type

    1

    child under 2

    pediatrician

    prescription

    fever

    phone

    2

    child

    dermatologist

    control check

    runny nose

    home-visit

    3

    child

    pediatrician

    infection

    rash & fever

    phone

    4

    adult

    dermatologist

    control check

    runny nose

    phone

    5

    child under 2

    dermatologist

    infection

    rash

    emergency

    6

    child under 2

    internist

    prescription

    rash & fever

    phone

    7

    adult

    pediatrician

    control check

    rash

    phone

    8

    adult

    internist

    infection

    fever

    home-visit

    9

    child under 2

    internist

    control check

    rash & fever

    home-visit

    10

    child under 2

    pediatrician

    prescription

    runny nose

    phone

    11

    adult

    pediatrician

    control check

    fever

    emergency

    12

    child

    internist

    prescription

    rash

    home-visit

    13

    child

    dermatologist

    control check

    fever

    emergency

    14

    child

    pediatrician

    infection

    rash

    home-visit

    15

    adult

    dermatologist

    prescription

    rash & fever

    emergency

    16

    adult

    internist

    infection

    runny nose

    emergency

    Conclusions:

    We can see that some pairs of values appear more than once, but this is inevitable, as covering test cases requires return values exactly fulfilling indicated path (to cover minimum amount of test cases with all pairs indicates creating cases where some parameters can have any value from given positive set of data).

    Comparing testing all combinations of values to Pairwise numbers makes a huge difference between 324 and 16 test cases.

  3. Provide data for AnkrPt Pairwise to mitigate risks connected with Pairwise technique.

    Assumptions:

    It is known that pairwise technique fails when highly probable or high-impact input value combinations get too little attention. To mitigate those risks we use Required Tests, to assure that those combinations are included in generated Test Suite.

    We define required tests for given example (empty values stand for "any valid value"):

    Table 1. Test Suite containing Pairwise Test Cases
    ID Person MD Purpose Symptoms Visit Type

    1

    dermatologist

    prescription

    rash

    phone

    2

    child

    pediatrician

    home-visit

    3

    child under 2

    rash & fever

    emergency

    Observations:

    Another run of Pairwise and we get brand new, polished Test Suite composed of 15 test cases, that includes high-risk / highly probable value combinations:

    Table 2. Test Suite containing Required Tests as a Pairwise Test Cases

    #

    Person

    MD

    Purpose

    Symptoms

    Visit Type

    1

    child under 2

    internist

    control check

    rash

    emergency

    2

    adult

    pediatrician

    control check

    rash & fever

    home-visit

    3

    adult

    dermatologist

    infection

    runny nose

    home-visit

    4

    adult

    internist

    control check

    rash

    emergency

    5

    child under 2

    pediatrician

    prescription

    fever

    home-visit

    6

    child under 2

    pediatrician

    prescription

    fever

    phone

    7

    child

    internist

    prescription

    rash & fever

    phone

    8

    child

    dermatologist

    infection

    rash

    phone

    9

    adult

    dermatologist

    prescription

    rash

    phone

    10

    adult

    internist

    infection

    fever

    home-visit

    11

    child

    pediatrician

    infection

    rash

    home-visit

    12

    child

    internist

    control check

    runny nose

    phone

    13

    child under 2

    dermatologist

    infection

    rash & fever

    emergency

    14

    child under 2

    pediatrician

    prescription

    runny nose

    emergency

    15

    child

    dermatologist

    control check

    fever

    emergency

    Conclusions:

    Adding required test to the suite does not mean that number of test cases will increase.

    Pairwise processes them at the beginning of the test case optimization, so they have impact on the process. There are situations where number of test cases may be smaller with required test than without them and this is proper behavior, as Pairwise will give you the best test suite with given input, and it may happen that required test will be better fit for further test generation.

  4. Don’t forget about negative testing!

    Assumptions:

    As we’ve got complete Test Suite covering "happy paths" for the application it is needed to provide tests covering negative values.

    We provide negative values that should be included in Test Suite:

    CRITERIA NAME     VALUES
    Person       elder,
    MD           nurse,	surgeon,
    Symptoms     none, pain,
    Visit Type   chat,	none,
    Purpose      giving birth,

    Observations:

    After another run of Pairwise we have completed Test suite composed with 15 "happy path" test cases (including required ones) and 8 negative test cases.

    Table 3. Test Suite containing Required Tests

    #

    Person

    MD

    Purpose

    Symptoms

    Visit Type

    <INVALID>

    1

    child under 2

    internist

    control check

    rash

    emergency

    2

    child under 2

    internist

    control check

    rash

    chat

    Visit Type

    3

    adult

    internist

    control check

    rash

    emergency

    4

    child under 2

    pediatrician

    prescription

    runny nose

    emergency

    5

    child

    internist

    prescription

    rash & fever

    phone

    6

    adult

    dermatologist

    prescription

    rash

    phone

    7

    adult

    surgeon

    prescription

    runny nose

    home-visit

    MD

    8

    child under 2

    nurse

    infection

    rash & fever

    emergency

    MD

    9

    elder

    pediatrician

    control check

    rash

    phone

    Person

    10

    child

    dermatologist

    control check

    fever

    emergency

    11

    child

    dermatologist

    giving birth

    fever

    phone

    Purpose

    12

    child

    dermatologist

    infection

    rash

    phone

    13

    adult

    pediatrician

    control check

    rash & fever

    home-visit

    14

    adult

    dermatologist

    infection

    runny nose

    home-visit

    15

    adult

    internist

    infection

    fever

    home-visit

    16

    child

    internist

    prescription

    pain

    home-visit

    Symptoms

    17

    child

    internist

    control check

    runny nose

    phone

    18

    child under 2

    dermatologist

    infection

    rash & fever

    emergency

    19

    adult

    pediatrician

    infection

    rash & fever

    none

    Visit Type

    20

    child

    pediatrician

    infection

    rash

    home-visit

    21

    adult

    dermatologist

    infection

    none

    emergency

    Symptoms

    22

    child under 2

    pediatrician

    prescription

    fever

    phone

    23

    child under 2

    pediatrician

    prescription

    fever

    home-visit

    AnkrPt PairWise Processing  for "c:\tmp\test.csv"
    -----------------------------
    Columns         - 5
      Largest       - 4
      Smallest      - 3
    
    Valid Values    - 16
    Negative Values - 8
    Total Pairs     - 102
    Cartesian Count - 324
    
    Total Tests     - 15
      Required      - 3    (*** included in total tests)
      Negative      - 8    (*** not included in total tests)
    
    Test data results saved to 'c:\tmp\test-output.csv'

    Conclusions:

    AnkrPt Pairwise is giving you Test Suite containing 15 positive test cases and 8 negative, to cover all system paths, highly probable and high-risk value combinations to give you opportunity to discover most defects that might occur during complex combinatorial testing.

  5. Improve your Test Suite with CONSTRAINTS!

    We provide constraints for our Test Suite: We know that child and child under 2 should be always treated by pediatrician, and rash as well as rash and fever should be treated by dermatologist or pediatrician(as it may be children issue).

    When

    Person

    isIn

    child,child under 2

    Then

    MD

    is

    pediatrician

    When

    Symptoms

    isIn

    rash & fever,rash

    Then

    MD

    isIn

    dermatologist,pediatrician

    During test generation, we get information, about pairs that were eliminated with Constraints:

    AnkrPt PairWise Processing  for "c:\tmp\test.csv"
    -----------------------------
    Columns         - 5
      Largest       - 4
      Smallest      - 3
    
    Valid Values    - 16
    Negative Values - 8
    Total Pairs     - 96
    Cartesian Count - 324
    
    Total Tests     - 17
      Required      - 3    (*** included in total tests)
      Negative      - 8    (*** not included in total tests)
    Generated in    - 55 ms
    
    Pairs filtered by constraints:
    0-child <> 1-dermatologist
    0-child <> 1-internist
    0-child under 2 <> 1-dermatologist
    0-child under 2 <> 1-internist
    3-rash & fever <> 1-internist
    3-rash <> 1-internist
    
    Test data results saved to 'c:\tmp\test-output.csv'
    Remember that numbers before criteria values stands for criteria index (order criteria were defined in Criteria section) to make it easier to identify them.

    #

    Person

    MD

    Purpose

    Symptoms

    Visit Type

    <INVALID>

    1

    adult

    internist

    prescription

    fever

    home-visit

    2

    adult

    dermatologist

    control check

    fever

    chat

    Visit Type

    3

    adult

    nurse

    control check

    fever

    emergency

    MD

    4

    child under 2

    pediatrician

    prescription

    rash & fever

    emergency

    5

    adult

    dermatologist

    prescription

    rash

    phone

    6

    child under 2

    pediatrician

    control check

    rash

    home-visit

    7

    child under 2

    pediatrician

    infection

    fever

    phone

    8

    child

    pediatrician

    control check

    rash & fever

    home-visit

    9

    adult

    dermatologist

    giving birth

    fever

    emergency

    Purpose

    10

    child

    pediatrician

    infection

    rash

    emergency

    11

    adult

    surgeon

    control check

    fever

    emergency

    MD

    12

    adult

    internist

    control check

    runny nose

    emergency

    13

    adult

    internist

    infection

    runny nose

    phone

    14

    child

    pediatrician

    control check

    rash & fever

    phone

    15

    adult

    pediatrician

    control check

    rash

    emergency

    16

    adult

    dermatologist

    control check

    none

    emergency

    Symptoms

    17

    adult

    dermatologist

    prescription

    runny nose

    home-visit

    18

    adult

    dermatologist

    control check

    fever

    none

    Visit Type

    19

    child

    pediatrician

    prescription

    fever

    phone

    20

    child under 2

    pediatrician

    control check

    runny nose

    emergency

    21

    adult

    dermatologist

    control check

    fever

    emergency

    22

    child

    pediatrician

    infection

    runny nose

    home-visit

    23

    adult

    dermatologist

    control check

    pain

    emergency

    Symptoms

    24

    elder

    dermatologist

    control check

    fever

    emergency

    Person

    25

    adult

    dermatologist

    infection

    rash & fever

    phone

    Conclusions:

    After another run of Pairwise we have completed Test suite composed with 17 "happy path" test cases (including required ones and constraints) and 8 negative ones, but those are more suited for our needs(as we can see, required test changed to meet constraints conditions).

  6. CONCLUSIONS:

    Summing up, AnkrPt Pairwise is a very handy tool that will make your work much easier. Even with complex Test Suite composed of positive, negative criteria, required test and constrains you will get significantly less test cases than with all value combinations (17 "happy path" cases and 8 negative ones, with constraints to 324 Cartesian Count that do not even cover negative cases).

    Pairwise require some time in preparing the data, constraints and requirements, as well as understanding the business processes. Testing planing with AnkrPt Pairwise is less time and budget consuming, easier to estimate, and easier to manage with application updates (once you have created your initial set, you can easily update as changes occur).