Black box & white-box testing technique

41
Testing Competency Testing Competency 1 White Box & Black Box White Box & Black Box Testing Techniques Testing Techniques Manish Manish Roopa S Roopa S

description

 

Transcript of Black box & white-box testing technique

Page 1: Black box & white-box testing technique

Testing CompetencyTesting Competency 11

White Box & Black BoxWhite Box & Black Box Testing Techniques Testing Techniques

Manish Manish

Roopa S Roopa S

Page 2: Black box & white-box testing technique

Testing CompetencyTesting Competency 22

What does Test meanWhat does Test mean

The word “TEST” is derived from the The word “TEST” is derived from the Latin word “Testum” meaning a Latin word “Testum” meaning a pottery vessel used to measure or pottery vessel used to measure or assessassess

Page 3: Black box & white-box testing technique

Testing CompetencyTesting Competency 33

Software TestingSoftware Testing

Testing of software means assessing or Testing of software means assessing or Measuring the software to determine Measuring the software to determine its QUALITY its QUALITY

Area of testing is one of the key process Area of testing is one of the key process areas of project life cycle in ensuring areas of project life cycle in ensuring the QUALITY of the softwarethe QUALITY of the software

Page 4: Black box & white-box testing technique

Testing CompetencyTesting Competency 44

QUALITYQUALITY

What is Quality product ?What is Quality product ?

A quality product is one which is fit for A quality product is one which is fit for use. use.

A quality product is one which is A quality product is one which is produced as per pre-defined produced as per pre-defined specifications.specifications.

Page 5: Black box & white-box testing technique

Testing CompetencyTesting Competency 55

Various Testing Various Testing TechniquesTechniques

Structural & FunctionalStructural & Functional Verification & Validation (V&V)Verification & Validation (V&V) Static & DynamicStatic & Dynamic White-Box & Black-BoxWhite-Box & Black-Box

Page 6: Black box & white-box testing technique

Testing CompetencyTesting Competency 66

Levels of TestingLevels of Testing

Levels of TestingLevels of Testing Testing TechniquesTesting Techniques

Unit TestingUnit Testing Structural Testing

IntegrationIntegration Structural & Functional

SystemSystem Functional, Risk based

AcceptanceAcceptance Functional, Risk based

Page 7: Black box & white-box testing technique

Testing CompetencyTesting Competency 77

Test Design MethodsTest Design Methods

Black-Box and White-Box are Test Black-Box and White-Box are Test Design MethodsDesign Methods

Page 8: Black box & white-box testing technique

Testing CompetencyTesting Competency 88

Black-Box TestingBlack-Box Testing

Black Box Testing is testing technique Black Box Testing is testing technique having no knowledge of the internal having no knowledge of the internal functionality/structure of the systemfunctionality/structure of the system

Synonyms for Black-Box are Behavioral, Synonyms for Black-Box are Behavioral, Functional, Opaque-Box, Closed-Box etc.Functional, Opaque-Box, Closed-Box etc.

Page 9: Black box & white-box testing technique

Testing CompetencyTesting Competency 99

contd…contd… Black-box Testing focuses on testing the Black-box Testing focuses on testing the

function of the program or application function of the program or application against its specificationagainst its specification

Determines whether combinations of inputs Determines whether combinations of inputs and operations produce expected resultsand operations produce expected results

When black box testing is applied to When black box testing is applied to software engineering, the tester would only software engineering, the tester would only know the "legal" inputs and what the know the "legal" inputs and what the expected outputs should be, but not how the expected outputs should be, but not how the program actually arrives at those outputsprogram actually arrives at those outputs

Page 10: Black box & white-box testing technique

Testing CompetencyTesting Competency 1010

Focus of Black-Box Focus of Black-Box Testing Testing

In this technique, we do not use the In this technique, we do not use the code to determine a test suite; code to determine a test suite; rather, knowing the problem that rather, knowing the problem that we're trying to solve, we come up we're trying to solve, we come up with four types of test data: with four types of test data:

Easy-to-compute data Easy-to-compute data Typical data Typical data Boundary / extreme data Boundary / extreme data Bogus data Bogus data

Page 11: Black box & white-box testing technique

Testing CompetencyTesting Competency 1111

Black-Box Testing Black-Box Testing TechniquesTechniques

Equivalence PartitioningEquivalence Partitioning Boundary Value AnalysisBoundary Value Analysis Error GuessingError Guessing Cause-Effect Graphing Cause-Effect Graphing

Page 12: Black box & white-box testing technique

Testing CompetencyTesting Competency 1212

Equivalence PartitioningEquivalence Partitioning

An equivalence class is a subset of data An equivalence class is a subset of data that is representative of a larger classthat is representative of a larger class

Equivalence partitioning is a technique Equivalence partitioning is a technique for testing equivalence classes rather for testing equivalence classes rather than undertaking exhaustive testing of than undertaking exhaustive testing of each value of the larger classeach value of the larger class

Page 13: Black box & white-box testing technique

Testing CompetencyTesting Competency 1313

Example - EPExample - EP

For example, a program which edits For example, a program which edits credit limits within a given range credit limits within a given range ($10,000 - $15,000) would have ($10,000 - $15,000) would have three equivalence classesthree equivalence classes < $10,000 (invalid)< $10,000 (invalid) Between $10,000 and $15,000 (valid)Between $10,000 and $15,000 (valid) > $15,000 (invalid)> $15,000 (invalid)

Page 14: Black box & white-box testing technique

Testing CompetencyTesting Competency 1414

Boundary AnalysisBoundary Analysis

This technique consists of developing This technique consists of developing test cases and data that focus on the test cases and data that focus on the input and output boundaries of a input and output boundaries of a given functiongiven function

Page 15: Black box & white-box testing technique

Testing CompetencyTesting Competency 1515

Example – Boundary Example – Boundary AnalysisAnalysis

In the same credit limit example, In the same credit limit example, boundary analysis would test.boundary analysis would test.

Low boundary -/+ one ($9,999 and Low boundary -/+ one ($9,999 and $10,001)$10,001)

On the boundary ($10,000 and $15,000)On the boundary ($10,000 and $15,000) Upper boundary -/+ one ($14,999 and Upper boundary -/+ one ($14,999 and

$15,001)$15,001)

Page 16: Black box & white-box testing technique

Testing CompetencyTesting Competency 1616

Error GuessingError Guessing

Test cases can be developed based Test cases can be developed based upon the intuition and experience of upon the intuition and experience of the testerthe tester

For example, where one of the inputs For example, where one of the inputs is the date, a tester may try February is the date, a tester may try February 29, 200129, 2001

Page 17: Black box & white-box testing technique

Testing CompetencyTesting Competency 1717

Cause-Effect GraphingCause-Effect Graphing

Cause-effect graphing is a technique Cause-effect graphing is a technique for developing test cases for for developing test cases for programs from the high-level programs from the high-level specifications (A high-level specifications (A high-level specification states desired specification states desired characteristics of the system)characteristics of the system)

These characteristics can be used to These characteristics can be used to derive test dataderive test data

Page 18: Black box & white-box testing technique

Testing CompetencyTesting Competency 1818

Example – Cause EffectExample – Cause Effect

For example, a program that has specified For example, a program that has specified responses to eight characteristic stimuli (called responses to eight characteristic stimuli (called causes) given some input has 256 "types" of causes) given some input has 256 "types" of input (i.e., those with characteristics 1 & 3; 5, input (i.e., those with characteristics 1 & 3; 5, 7 & 8 etc.)7 & 8 etc.)

A poor approach is to generate 256 test casesA poor approach is to generate 256 test cases A more methodical approach is to use the A more methodical approach is to use the

program specifications to analyze the program specifications to analyze the program's effect on the various types of inputsprogram's effect on the various types of inputs

Page 19: Black box & white-box testing technique

Testing CompetencyTesting Competency 1919

contd…contd… The program's output domain can be The program's output domain can be

partitioned into various classes called effectspartitioned into various classes called effects For example, inputs with characteristic 2 For example, inputs with characteristic 2

might be subsumed by those with might be subsumed by those with characteristics 3 & 4. Hence, it would not be characteristics 3 & 4. Hence, it would not be necessary to test inputs with characteristic 2 necessary to test inputs with characteristic 2 and characteristics 3 & 4, for they cause the and characteristics 3 & 4, for they cause the same effectsame effect

This analysis results in a partitioning of the This analysis results in a partitioning of the causes according to their corresponding causes according to their corresponding effectseffects

Page 20: Black box & white-box testing technique

Testing CompetencyTesting Competency 2020

contd…contd… A limited entry decision table is then A limited entry decision table is then

constructed from the directed graph reflecting constructed from the directed graph reflecting these dependencies (i.e., causes 2 & 3 result in these dependencies (i.e., causes 2 & 3 result in effect 4; causes 2, 3 & 5 result in effect 6 etc.)effect 4; causes 2, 3 & 5 result in effect 6 etc.)

The decision table is then reduced and test The decision table is then reduced and test cases chosen to exercise each column of the cases chosen to exercise each column of the tabletable

Since many aspects of the cause-effect Since many aspects of the cause-effect graphing can be automated, it is an attractive graphing can be automated, it is an attractive tool for aiding in the generation of Functional tool for aiding in the generation of Functional Test casesTest cases

Page 21: Black box & white-box testing technique

Testing CompetencyTesting Competency 2121

Advantages of Black-Box Advantages of Black-Box TestingTesting

More effective on larger units of code More effective on larger units of code than glass box testingthan glass box testing

Tester needs no knowledge of Tester needs no knowledge of implementation, including specific implementation, including specific programming languagesprogramming languages

Tester and programmer are Tester and programmer are independent of each other independent of each other

Page 22: Black box & white-box testing technique

Testing CompetencyTesting Competency 2222

Advantages of Black-Box Advantages of Black-Box Testing Contd…Testing Contd…

Tests are done from a user's point of Tests are done from a user's point of viewview

Will help to expose any ambiguities or Will help to expose any ambiguities or

inconsistencies in the specifications inconsistencies in the specifications

Test cases can be designed as soon as Test cases can be designed as soon as the specifications are completethe specifications are complete

Page 23: Black box & white-box testing technique

Testing CompetencyTesting Competency 2323

Disadvantages of Black-Box Disadvantages of Black-Box TestingTesting

Only a small number of possible inputs can Only a small number of possible inputs can actually be tested, to test every possible actually be tested, to test every possible input stream would take nearly foreverinput stream would take nearly forever

Without clear and concise specifications, Without clear and concise specifications, test cases are hard to design test cases are hard to design

There may be unnecessary repetition of There may be unnecessary repetition of test inputs if the tester is not informed of test inputs if the tester is not informed of test cases the programmer has already test cases the programmer has already tried tried

Page 24: Black box & white-box testing technique

Testing CompetencyTesting Competency 2424

Disadvantages of Black-Box Disadvantages of Black-Box Testing Contd…Testing Contd…

May leave many program paths May leave many program paths untested untested

Cannot be directed toward specific Cannot be directed toward specific segments of code which may be very segments of code which may be very complex (and therefore more error complex (and therefore more error prone) prone)

Page 25: Black box & white-box testing technique

Testing CompetencyTesting Competency 2525

White-Box TestingWhite-Box Testing

White-box test design allows one to White-box test design allows one to peek inside the "box“peek inside the "box“

Synonyms for White-box are Synonyms for White-box are Structural, Glass-box and Clear-boxStructural, Glass-box and Clear-box

Page 26: Black box & white-box testing technique

Testing CompetencyTesting Competency 2626

cont…cont…

White-box Testing assumes that the White-box Testing assumes that the path of logic in a unit or program is path of logic in a unit or program is knownknown

White-box Testing consists of testing White-box Testing consists of testing paths, branch by branch, to produce paths, branch by branch, to produce predictable resultspredictable results

Focuses specifically on using internal Focuses specifically on using internal knowledge of the software to guide knowledge of the software to guide the selection of test datathe selection of test data

Page 27: Black box & white-box testing technique

Testing CompetencyTesting Competency 2727

White-Box Testing White-Box Testing TechniquesTechniques

Statement CoverageStatement Coverage execute all statements at least onceexecute all statements at least once

Decision CoverageDecision Coverage execute each decision direction at least execute each decision direction at least

onceonce Condition CoverageCondition Coverage

execute each decision with all possible execute each decision with all possible outcomes at least onceoutcomes at least once

Page 28: Black box & white-box testing technique

Testing CompetencyTesting Competency 2828

cont…cont…

Decision/Condition CoverageDecision/Condition Coverage execute all possible combinations of execute all possible combinations of

condition outcomes in each decisioncondition outcomes in each decision Multiple Condition CoverageMultiple Condition Coverage

invoke each point of entry at least onceinvoke each point of entry at least once

Choose the combinations of Choose the combinations of techniques appropriate for the techniques appropriate for the applicationapplication

Page 29: Black box & white-box testing technique

Testing CompetencyTesting Competency 2929

Statement CoverageStatement Coverage Necessary but not sufficient, doesn’t Necessary but not sufficient, doesn’t

address all outcomes of decisionsaddress all outcomes of decisions For exampleFor example…………..Begin()Begin()If (function1())If (function1())

OpenFile1()OpenFile1()ElseElse

Shutdown();Shutdown();……………… Here if the first IF statement is true then Here if the first IF statement is true then

Shutdown will never occurShutdown will never occur

Page 30: Black box & white-box testing technique

Testing CompetencyTesting Competency 3030

Decision CoverageDecision Coverage

Validates the Branch Statements in Validates the Branch Statements in softwaresoftware

Overcomes the drawbacks of statement Overcomes the drawbacks of statement coveragecoverage

Each decision is tested for a TrueEach decision is tested for a True & & False False valuevalue

Each branch direction must be traversed at Each branch direction must be traversed at least onceleast once

Branches like if…else, while, for do...while Branches like if…else, while, for do...while are to be evaluated for both true and falseare to be evaluated for both true and false

Test cases will be arrived with the help of a Test cases will be arrived with the help of a Decision tableDecision table

Page 31: Black box & white-box testing technique

Testing CompetencyTesting Competency 3131

Cont…Cont…

Decision TableDecision Table

• Table which helps to derive the test casesTable which helps to derive the test cases

StepsSteps

• Identify the variables which are Identify the variables which are responsible for decisionresponsible for decision

• Identify the total number of decisions Identify the total number of decisions (Give numbers to them like IF1, IF2… (Give numbers to them like IF1, IF2… While1, While2 etc)While1, While2 etc)

• Put the Put the variablesvariables as rows and as rows and decisionsdecisions as as verticalsverticals

• Start to map the values for each variables Start to map the values for each variables corresponding to each decisionscorresponding to each decisions

Page 32: Black box & white-box testing technique

Testing CompetencyTesting Competency 3232

An ExampleAn ExampleProcedure liability (age, sex, married, premium); Procedure liability (age, sex, married, premium); beginbegin

premium=500;premium=500;If ((age<25) and (sex=male) and (not married)) If ((age<25) and (sex=male) and (not married))

IF-1IF-1thenthenpremium=Premium+1500;premium=Premium+1500;elseelse(if (married or (sex=female))(if (married or (sex=female))

IF-2IF-2thenthenpremium=premium-200;premium=premium-200;If( (age>45) and (age<65))If( (age>45) and (age<65))

IF-3IF-3thenthenpremium= premium-100;premium= premium-100;

end; end;

Here variables are Here variables are age, sexage, sex and and married married Decisions are IF1; IF2 ; IF3 Decisions are IF1; IF2 ; IF3

Page 33: Black box & white-box testing technique

Testing CompetencyTesting Competency 3333

DecisionDecision

CoverageCoverageAgeAge SexSex MarriedMarried Test Test

casecase

IF-1IF-1 <25<25 MaleMale FalseFalse (1) 23 M (1) 23 M FF

IF-1IF-1 <25<25 FemaleFemale FalseFalse (2) 23 F F(2) 23 F F

IF-2IF-2 ** FemaleFemale ** (2)(2)

IF-2IF-2 >=25 >=25 MaleMale FalseFalse (3) 50 M (3) 50 M FF

IF-3IF-3 <=45<=45 FemaleFemale ** (2)(2)

IF-3IF-3 >45>45

<65<65** ** (3)(3)

Decision TableDecision Table

Page 34: Black box & white-box testing technique

Testing CompetencyTesting Competency 3434

Condition CoverageCondition Coverage

Validates logical relations and conditionsValidates logical relations and conditions All the conditions should be executed at All the conditions should be executed at

least once for the both false and trueleast once for the both false and true Conditions using relational and logical Conditions using relational and logical

operators should be checked for all possible operators should be checked for all possible outcomesoutcomes

Condition coverage checks for true and false Condition coverage checks for true and false outcome of each Boolean sub expressionoutcome of each Boolean sub expression

Test cases will be arrived from using same Test cases will be arrived from using same Decision table by putting conditions in place Decision table by putting conditions in place of decisionsof decisions

Page 35: Black box & white-box testing technique

Testing CompetencyTesting Competency 3535

Test conditionsTest conditions

ConditionCondition

CoverageCoverageAgeAge SexSex MarriedMarried Test CaseTest Case

IF-1IF-1 <25<25 FemaleFemale FalseFalse (1) 23 F F(1) 23 F F

IF-1IF-1 >=25>=25 MaleMale TrueTrue (2) 30 M T(2) 30 M T

IF-2IF-2 ** MaleMale TrueTrue (2)(2)

IF-2IF-2 ** FemaleFemale FalseFalse (1)(1)

IF-3IF-3 <=45<=45 ** ** (1)(1)

IF-3IF-3 >45>45 ** ** (3) 70 F F(3) 70 F F

IF-3IF-3 <65<65 ** ** (2)(2)

IF-3IF-3 >=65>=65 ** ** (3)(3)

Page 36: Black box & white-box testing technique

Testing CompetencyTesting Competency 3636

Condition/Decision Coverage

We may not always get result either in decision coverage or condition coverage. In such cases, go in for decision & condition coverage

Test cases will be arrived form both decision as well as condition coverage

Page 37: Black box & white-box testing technique

Testing CompetencyTesting Competency 3737

Condition/Decision Test Condition/Decision Test casecase

Decision/condition Decision/condition coveragecoverage

AgeAge SexSex MarriedMarried Test CaseTest Case

IF-1(decision)IF-1(decision) <25<25 MaleMale FalseFalse (1) 23 M F(1) 23 M F

IF-1(decision)IF-1(decision) <25<25 FemaleFemale FalseFalse (2) 23 F F(2) 23 F F

IF-1(condition)IF-1(condition) <25<25 FemaleFemale FalseFalse (2)(2)

IF-1(condition)IF-1(condition) >=25>=25 MaleMale TrueTrue (3) 70 M T(3) 70 M T

IF-2(decision)IF-2(decision) ** FemaleFemale ** (2)(2)

IF-2(decision)IF-2(decision) >=25>=25 MaleMale FalseFalse (4) 50 M F(4) 50 M F

IF-2(condition)IF-2(condition) ** MaleMale TrueTrue (3)(3)

IF-2(condition)IF-2(condition) ** FemaleFemale FalseFalse (2)(2)

IF-3(decision)IF-3(decision) <=45<=45 ** ** (2)(2)

IF-3(decision)IF-3(decision) >45, <65>45, <65 ** ** (4)(4)

IF-3(condition)IF-3(condition) <=45<=45 ** ** (2)(2)

IF-3(condition)IF-3(condition) >45>45 ** ** (4)(4)

IF-3(condition)IF-3(condition) <65<65 ** ** (4)(4)

IF-3(condition)IF-3(condition) >=65>=65 ** ** (3)(3)

Page 38: Black box & white-box testing technique

Testing CompetencyTesting Competency 3838

Multiple Condition Multiple Condition CoverageCoverage

Checks whether every possible combination Checks whether every possible combination of Boolean sub expression occurs at least of Boolean sub expression occurs at least once (2n), where “n” is the number of once (2n), where “n” is the number of variables in a given branchvariables in a given branch

Test cases required for this method can be Test cases required for this method can be arrived at by using truth table of the arrived at by using truth table of the conditionsconditions

Large number of test cases may be Large number of test cases may be required for full multiple condition coveragerequired for full multiple condition coverage

Page 39: Black box & white-box testing technique

Testing CompetencyTesting Competency 3939

Multiple Conditions Coverage – Test cases

Multiple condition coverageMultiple condition coverage AgeAge SexSex MarriedMarried Test CaseTest Case

IF-1IF-1 <25<25 MaleMale TrueTrue (1) 23 M T(1) 23 M T

IF-1IF-1 <25<25 MaleMale FalseFalse (2) 23 M F(2) 23 M F

IF-1IF-1 <25<25 FemaleFemale TrueTrue (3) 23 F T(3) 23 F T

IF-1IF-1 <25<25 FemaleFemale FalseFalse (4) 23 F F(4) 23 F F

IF-1IF-1 >=25>=25 MaleMale TrueTrue (5) 30 M T(5) 30 M T

IF-1IF-1 >=25>=25 MaleMale FalseFalse (6) 70 M F(6) 70 M F

IF-1IF-1 >=25>=25 FemaleFemale TrueTrue (7) 50 F T(7) 50 F T

IF-1IF-1 >=25>=25 FemaleFemale FalseFalse (8) 30 F F(8) 30 F F

IF-2IF-2 ** MaleMale TrueTrue (5) (5)

IF-2IF-2 ** MaleMale FalseFalse (6)(6)

IF-2IF-2 ** FemaleFemale TrueTrue (7) (7)

IF-2IF-2 ** FemaleFemale FalseFalse (8)(8)

IF-3IF-3 <=45, >=65<=45, >=65 ** ** ImpossibleImpossible

IF-3IF-3 <=45,<65<=45,<65 ** ** (8)(8)

IF-3IF-3 >45, >=65>45, >=65 ** ** (6) (6)

IF-3IF-3 >45, <65>45, <65 ** ** (7)(7)

Page 40: Black box & white-box testing technique

Testing CompetencyTesting Competency 4040

Gray-Box TestingGray-Box Testing: An Introduction: An Introduction

Blending of Structural and Functional Blending of Structural and Functional Testing methods throughout the Testing methods throughout the entire testing procedureentire testing procedure

Examines the activity of back-end Examines the activity of back-end components during test case components during test case execution execution

Page 41: Black box & white-box testing technique

Testing CompetencyTesting Competency 4141

Thank you !Thank you !