Black Box Testing is a software testing method in which the internal structure/ design/ implementation of the item being tested is not known to the tester. White Box Testing is a software testing method in which the internal structure/ design/ implementation of the item being tested is known to the tester.
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
Black-box-testing & white-box-testing
1. AGENDA
1. Test case Design strategy
Black Box Testing
White Box Testing
3. Black Box Testing
Quality Goal Identification
Equivalence class partitioning
Boundary value analysis
4. White Box Testing
Path Coverage
4. QUALITY GOAL IDENTIFICATION
Goal Sub-factor Requirement Description
Functionality Accuracy •The bill of the medicines will be
calculated in Rupees accurately
in 2 fp with respect to their
prices.
•The generated report will
contain the patient name, the
test he wants and the total bill.
The bill of the required test
should be accurately calculated
by the system in Rupees.
It means that the system should
be able to accurately calculate
the bills up to 2 fp in Rupees.
For Example: The pharmacy bill
and the lab tests total bill.
5. QUALITY GOAL IDENTIFICATION
Goal Sub-factor Requirement Description
Functionality Security •If the unauthorized person
want to login “Login
unsuccessful” message
will be displayed.
•The password should be
between 6-9 characters
It means that the system
should be secure no
unauthorized person will
be able to access the
details of the system. For
Example: The
administration, patient,
doctor has their own
accounts and they can
access them only.
6. QUALITY GOAL IDENTIFICATION
Goal Sub-factor Requirement Description
Usability Operability •The user can be able to go
back on the previous page
and home page
•No field will be left
emptied. If any field will be
left emptied then it will give
an error message “No field
can be left emptied”
It means that the system
should be easy to use. For
Example: The system is
providing the facility to go
back on previous page and
home, and gives help
messages so that the user
will understand what action
they need to take. The use
of drop down menus
7. QUALITY GOAL IDENTIFICATION
Goal Sub-factor Requirement Description
Efficiency Time Behavior •The system should
generate the report of the
lab tests within 3 seconds.
It means that the system
should be efficient in terms
of time. For Example: The
reports of the lab tests
should be generated within
time of 3 seconds without
delay so that they can be
immediately emailed to the
patient or give him the print
9. BLACK BOX TESTING
Goal: Functionality –Accuracy
Test Data
Input Object ECP BVA
Bill
Valid Invalid Valid Invalid
Min Max Min Max
Bill=2fp 2fp>Bill>2fp 2fp 2fp 1fp 3fp
Test Case - ECP
Valid
Test Case id 1 2
Input: Bill 23.00 879.89
E.C.P Tested Bill=2fp Bill=2fp
Expected output Valid/Ok Valid/ok
Test Case - ECP
Invalid
Test Case id 1 2
Input: Bill 89 23.1
E.C.P Tested
2fp>Bill>2fp 2fp>Bill>2fp
Expected output
Invalid Invalid
Test Case - BVA
Valid
Test Case id 1 2
Input: Bill 34.00 567.89
BVA Tested Bill=2fp Bill=2fp
Expected output
Valid/Ok Valid/Ok
Test Case - BVA
Invalid
Test Case id 1 2
Input: Bill 23.1 45.678
BVA Tested 2fp>Bill>2fp 2fp>Bill>2fp
Expected output Invalid Invalid
Test case title: Bill calculation up to 2 Fp
Technique: Black Box Test data generation: E.CP+B.V
10. BLACK BOX TESTING
Goal: Functionality-Security
Test case title: Authorize Access
Technique: Black Box Test Data generation technique: E.CP
Test Data
Input Object ECP
Authorize access
Valid Invalid
Patient={P1,P2…Pn}
Doctor={D1,D2…Dn}
Admin={A1,A2….An}
Patient={outside of the valid class}
Doctor={outside of the valid class}
Admin={outside of the valid class}
Test Case - ECP
Valid
Test Case id 1 2
Input: authorize
access
A1 A2
E.C.P Tested
Admin={A1,A2….
An}
Admin={A1,A2….
An}
Expected output Valid/ok
Valid/ok
Test Case - ECP
Invalid
Test Case id 1 2
Input: authorize access P1 D1
E.C.P Tested
Admin={outside
of the valid
class}
Admin={outside of
the valid class}
Expected output Invalid Invalid
11. BLACK BOX TESTING
Goal: Functionality-Security
Test case title: Authorize Access
Technique: Black Box Test Data generation technique: E.CP
Test Data
Input Object ECP
User name
Valid Invalid
Username= {alphabet, number } Username != special character
Test Case - ECP
Valid
Test Case id 1 2
Input: user name aliahmad 123234567
E.C.P Tested
Username=
{alphabet, number }
Username=
{alphabet, number
}
Expected output Valid/ok
Valid/ok
Test Case - ECP
Invalid
Test Case id 1 2
Input: user name &*& +(-
E.C.P Tested
Username !=
special character
Username !=
special character
Expected output Invalid Invalid
12. BLACK BOX TESTING
Goal: Functionality-Security
Test case title: Authorize Access
Technique: Black Box Test Data generation technique: E.CP
Test Data
Input Object ECP BVA
password
Valid Invalid Valid Invalid
Min Max Min Max
6<Password<9 6>password>9, 6 9 5 10
Test Case - ECP
Valid
Test Case id 1 2
Input: password 7 8
E.C.P Tested 6<Password<9 6<Password<9
Expected output Valid/Ok Valid/ok
Test Case - ECP
Invalid
Test Case id 1 2
Input: password 4 11
E.C.P Tested 6>password>9
6>password>9
Expected output
Invalid Invalid
Test Case - BVA
Valid
Test Case id 1 2
Input: password 6 9
BVA Tested 6<Password<9 6<Password<9
Expected output
Valid/Ok Valid/Ok
Test Case - BVA
Invalid
Test Case id 1 2
Input: password 5 10
BVA Tested 6>password>9 6>password>9
Expected output Invalid Invalid
13. BLACK BOX TESTING
Goal: Efficiency- Time
Test case title: Efficiency in terms of time
Technique: Black Box testing Test data generation technique: E.C.P+B.V
Test Data
Input Object ECP BVA
Report Generation
Time(RGT)
Valid Invalid Valid Invalid
Min Max Min Max
0<RGT<=3 sec 0>RGT>=3 sec
0 sec 3 sec -1 sec 4 sec
Test Case - ECP
Valid
Test Case id 1 2
Input: RGT 1 2
E.C.P Tested 0<RGT<=3 sec 0<RGT<=3 sec
Expected output Valid/ok Valid/ok
Test Case - ECP
Invalid
Test Case id 1 2
Input: RGT 5 11
E.C.P Tested
0>RGT>=3 sec 0>RGT>=3 sec
Expected output
Invalid Invalid
Test Case - BVA
Valid
Test Case id 1 2
Input: RGT 0 3
BVA Tested 0<RGT<=3 sec 0<RGT<=3 sec
Expected output
Valid/Ok Valid/Ok
Test Case - BVA
Invalid
Test Case id 1 2
Input: RGT -1 4
BVA Tested 0>RGT>=3 sec 0>RGT>=3 sec
Expected output Invalid Invalid
19. WHITE BOX TESTING
Testing Technique
Statement coverage:
We will not do statement coverage here because this chunk of code includes different decision
statements. To test every statement is exhaustive and impossible due to many reasons like time etc.
Branch Coverage:
If we will only test true and false branches it will not ensure the testing of all statements. May be some
statements are critical and need to be tested.
Path Coverage:
As this code includes multiple if and else conditions which makes the code complex. There are multiple
decision statements.
20. WHITE BOX TESTING
Path1: (abc)
Income < 0 [Negative income]
Code:
if (Income < 0)
{
cout << "You cannot have a negative income.n";
return 0;
}
21. WHITE BOX TESTING
Path2: (adefg)
Income >= 0, nDependents <= 0
[Invalid dependants]
Code:
cout << "Enter the number of dependents you have, including yourself: ";
cin >> nDependents;
// second if - check dependents
if (nDependents <= 0)
{
cout <<"You must have at least one dependent.n";
return 0;
}
22. WHITE BOX TESTING
Path3: (adehijpqr)
Income >= 0, nDependents > 0
Income < 10000, Tax Total < 0
[Negative tax]
Code:
// third if (else-if) - compute tax subtotal
if (Income < 10000)
TaxSubTotal = .02 * Income;
Exemption= nDependents * 50;
TaxTotal=TaxSubTotal - Exemption;
if (TaxTotal<0)
//In case of negative tax
TaxTotal=0;
23. WHITE BOX TESTING
Path4: (adehklmpqr)
Income >= 0
nDependents > 0
10000 <= Income < 50000
Tax Total < 0
[Negative tax]
Code:
else if (Income < 50000)
TaxSubTotal = 200 + .03 * (Income - 10000);
Exemption= nDependents * 50;
TaxTotal=TaxSubTotal - Exemption;
if (TaxTotal<0)
//In case of negative tax
TaxTotal=0;
24. WHITE BOX TESTING
Path5: (adehknopqr)
Income >= 0
nDependents > 0
Income >= 50000
Tax Total < 0
[Negative Tax]
Code:
else
TaxSubTotal = 1400 + .04 * (Income - 50000);
Exemption= nDependents * 50;
TaxTotal=TaxSubTotal - Exemption;
// last if - check negative tax
if (TaxTotal<0) //In case of negative tax TaxTotal=0;
25. WHITE BOX TESTING
Path6: (adehijpqt)
Income >= 0
NDependents > 0
Income < 10000
Tax Total >= 0
[Total Tax]
Code:
// third if (else-if) - compute tax subtotal
if (Income < 10000)
TaxSubTotal = .02 * Income;
Exemption= nDependents * 50;
TaxTotal=TaxSubTotal - Exemption;
// last if - check negative tax
if (TaxTotal<0) //In case of negative tax
TaxTotal=0;
26. WHITE BOX TESTING
Path7: (adehklmpqt)
Income >= 0
NDependents > 0
10000 <= Income < 50000
Tax Total >= 0
Code:
else if (Income < 50000)
TaxSubTotal = 200 + .03 * (Income - 10000);
else
TaxSubTotal = 1400 + .04 * (Income - 50000);
Exemption= nDependents * 50;
TaxTotal=TaxSubTotal - Exemption;
// last if - check negative tax
if (TaxTotal<0) //In case of negative tax
TaxTotal=0;
27. Path8: (adehknopqt)
Income >= 0
NDependents > 0
Income >= 50000
Tax Total >= 0
[Total Tax]
Code:
else
TaxSubTotal = 1400 + .04 * (Income - 50000);
Exemption= nDependents * 50;
TaxTotal=TaxSubTotal - Exemption;
// last if - check negative tax
if (TaxTotal<0) //In case of negative tax
TaxTotal=0;
30. Path Decisions Edges/links Prior
ity
2 5 7 9 14 a b c d e f g h i j k l m n o p q r t
abc Y P8
adefg Y Y P7
adehijpq
r
Y Y Y P6
adehklm
pqr
Y Y Y Y P1
adehkn
opqr
Y Y Y Y Y P3
adehijpq
t
Y Y Y Y P2
adehklm
pqt
Y Y Y Y P5
adehkn
opqt
Y Y Y Y Y P4
33. WHITE BOX TESTING
Test Case title: Negative tax
Technique: Path Coverage
Test Data
Input Object
Income
nDependent
Path Tested
nDependents > 0 , 10000 <= Income <
50000, Tax Total < 0
Red Path
Test Case
Test Case id 1
Input: Income
40000
Path Tested Red Path
Expected output Negative Tax
Test Case
Test Case id 1
Input: nDependent
11
Path Tested Red Path
Expected output Negative Tax
34. WHITE BOX TESTING
Test Case title: Total Tax
Technique: Path Coverage
Test Data
Input Object
Income
nDependent
Path Tested
NDependents > 0, Income < 10000
Tax Total >= 0
Orange Path
Test Case
Test Case id 1
Input: Income
8000
Path Tested Orange Path
Expected output Total Tax
Test Case
Test Case id 1
Input: nDependent
8
Path Tested Orange Path
Expected output Total Tax