0% found this document useful (0 votes)
3 views

Object Oriented Software Enginnering lec 3

The document presents an overview of White-Box Testing Techniques, which involve testing a software application's internal structure using the source code to design test cases. It details various testing methods such as Statement Coverage, Branch Coverage, and Basis Path Testing, along with their processes and advantages. It also discusses the features, advantages, and disadvantages of white-box testing, emphasizing the need for programming knowledge and access to source code.

Uploaded by

ritu.bansal312
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Object Oriented Software Enginnering lec 3

The document presents an overview of White-Box Testing Techniques, which involve testing a software application's internal structure using the source code to design test cases. It details various testing methods such as Statement Coverage, Branch Coverage, and Basis Path Testing, along with their processes and advantages. It also discusses the features, advantages, and disadvantages of white-box testing, emphasizing the need for programming knowledge and access to source code.

Uploaded by

ritu.bansal312
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Object Oriented Software Engineering

(OOSE)
22CS017

White-Box Testing Techniques

Lecture (Theory)
Prepared By Dr. Neha Sharma
Index

• White-Box Testing Techniques:

• Basis Path Testing

• Control Structure Testing: condition and loop testing


3

White-Box Testing Techniques


• A software testing technique that involves testing a software application's
internal structure and workings.
• The tester has access to the source code and uses this knowledge to design test
cases that can verify the correctness of the software at the code level.
• Analyze the internal structures of the used data structures, internal design, code
structure, and the software’s working rather than just the functionality as in
black box testing.
• Also, called glass box testing clear box testing, or structural testing.
• Also, known as transparent testing or open-box testing.
• Also, known as structural testing or code-based testing, it is used to test the
software’s internal logic, flow, and structure.
• The tester creates test cases to examine the code paths and logic flows to ensure
they meet the specified requirements.
4

White-Box Testing Techniques

Process of White Box Testing


1. Input: Requirements, Functional specifications, design documents, source
code.

2. Processing: Performing risk analysis to guide through the entire process.

3. Proper test planning: Designing test cases to cover the entire code. Execute
rinse-repeat until error-free software is reached. Also, the results are
communicated.

4. Output: Preparing the final report of the entire testing process.


5

White-Box Testing Techniques


Testing Techniques
1. Statement Coverage
In this technique as shown in Figure 1, the aim is to traverse all statements at least
once. Hence, each line of code is tested. In the case of a flowchart, every node
must be traversed at least once. Since all lines of code are covered, it helps in
pointing out faulty code.

Figure 1: Statement Coverage Example.


6

White-Box Testing Techniques


2. Branch Coverage:
In this technique as shown in Figure 2, test cases are designed so that each branch
from all decision points is traversed at least once. In a flowchart, all edges must be
traversed at least once.

Figure 2: 4 test cases are required such that all branches of all decisions are covered, i.e, all edges of the flowchart are covere
7

White-Box Testing Techniques


3. Condition Coverage
In this technique, all individual conditions must be covered as shown in the
following example:
•READ X, Y
•IF(X == 0 || Y == 0)
•PRINT ‘0’
•#TC1 – X = 0, Y = 55
•#TC2 – X = 5, Y = 0
8

White-Box Testing Techniques

4. Multiple Condition Coverage


In this technique, all the possible combinations of the possible outcomes of
conditions are tested at least once. Let’s consider the following example:
•READ X, Y
•IF(X == 0 || Y == 0)
•PRINT ‘0’
•#TC1: X = 0, Y = 0
•#TC2: X = 0, Y = 5
•#TC3: X = 55, Y = 0
•#TC4: X = 55, Y = 5
9

White-Box Testing Techniques


5. Basis Path Testing
In this technique, control flow graphs are made from code or flowchart and then
Cyclomatic complexity is calculated which defines the number of independent
paths so that the minimal number of test cases can be designed for each
independent path.
Steps:
•Make the corresponding control flow graph
•Calculate the cyclomatic complexity
•Find the independent paths
•Design test cases corresponding to each independent path
•V(G) = P + 1, where P is the number of predicate nodes in the flow graph
•V(G) = E – N + 2, where E is the number of edges and N is the total number of
nodes
•V(G) = Number of non-overlapping regions in the graph
•#P1: 1 – 2 – 4 – 7 – 8
•#P2: 1 – 2 – 3 – 5 – 7 – 8
•#P3: 1 – 2 – 3 – 6 – 7 – 8
•#P4: 1 – 2 – 4 – 7 – 1 – . . . – 7 – 8
10

White-Box Testing Techniques


6. Loop Testing
Loops are widely used and these are fundamental to many algorithms hence, their
testing is very important. Errors often occur at the beginnings and ends of loops.

•Simple loops: For simple loops of size n, test cases are designed that:
1.Skip the loop entirely
2.Only one pass through the loop
3.2 passes
4.m passes, where m < n
5.n-1 ans n+1 passes
11

White-Box Testing Techniques

6. Loop Testing (cont’d)


•Nested loops:
• For nested loops, all the loops are set to their minimum count, and we start from
the innermost loop.
• Simple loop tests are conducted for the innermost loop and this is worked
outwards till all the loops have been tested.
•Concatenated loops:
• Independent loops, one after another. Simple loop tests are applied for each. If
they’re not independent, treat them like nesting.
12

White-Box Testing Techniques


White Testing is performed in 2 Steps

1.Tester should understand the code well


2.Tester should write some code for test cases and execute them

Tools required for White box testing:


•PyUnit
•Sqlmap
•Nmap
•Parasoft Jtest
•Nunit
•VeraUnit
•CppUnit
•Bugzilla
•Fiddler
•JSUnit.net
•OpenGrok
•Wireshark
•HP Fortify
•CSUnit
13

White-Box Testing Techniques


Features of White-Box Testing
1.Code coverage analysis: White box testing helps to analyze the code coverage of an
application, which helps to identify the areas of the code that are not being tested.
2.Access to the source code: White box testing requires access to the application’s source
code, which makes it possible to test individual functions, methods, and modules.
3.Knowledge of programming languages: Testers performing white box testing must have
knowledge of programming languages like Java, C++, Python, and PHP to understand the
code structure and write tests.
4.Identifying logical errors: White box testing helps to identify logical errors in the code,
such as infinite loops or incorrect conditional statements.
5.Integration testing: White box testing is useful for integration testing, as it allows testers to
verify that the different components of an application are working together as expected.
6.Unit testing: White box testing is also used for unit testing, which involves testing
individual units of code to ensure that they are working correctly.
14

White-Box Testing Techniques


Features of White-Box Testing (continued…)
7.Optimization of code: White box testing can help to optimize the code by identifying any
performance issues, redundant code, or other areas that can be improved.
8.Security testing: White box testing can also be used for security testing, as it allows testers to
identify any vulnerabilities in the application’s code.
9.Verification of Design: It verifies that the software’s internal design is implemented by the
designated design documents.
10.Check for Accurate Code: It verifies that the code operates per the guidelines and
specifications.
11.Identifying Coding Mistakes: It finds and fixes programming flaws in your code, including
syntactic and logical errors.
12.Path Examination: It ensures that each possible path of code execution is explored and tests
various iterations of the code.
13.Determining the Dead Code: It finds and removes any code that isn’t used when the program
is running normally (dead code).
15

White-Box Testing Techniques


Advantages of Whitebox Testing
1.Thorough Testing: White box testing is thorough as the entire code and structures are
tested.
2.Code Optimization: It results in the optimization of code removing errors and helps in
removing extra lines of code.
3.Early Detection of Defects: It can start at an earlier stage as it doesn’t require any interface
as in the case of black box testing.
4.Integration with SDLC: White box testing can be easily started in the Software
Development Life Cycle.
5.Detection of Complex Defects: Testers can identify defects that cannot be detected through
other testing techniques.
6.Comprehensive Test Cases: Testers can create more comprehensive and effective test cases
that cover all code paths.
7.Testers can ensure that the code meets coding standards and is optimized for performance.
16

White-Box Testing Techniques


Disadvantages of White box Testing
1.Programming Knowledge and Source Code Access: Testers need to have programming
knowledge and access to the source code to perform tests.
2.Overemphasis on Internal Workings: Testers may focus too much on the internal
workings of the software and may miss external issues.
3.Bias in Testing: Testers may have a biased view of the software since they are familiar with
its internal workings.
4.Test Case Overhead: Redesigning code and rewriting code needs test cases to be written
again.
5.Dependency on Tester Expertise: Testers are required to have in-depth knowledge of the
code and programming language as opposed to black-box testing.
6.Inability to Detect Missing Functionalities: Missing functionalities cannot be detected as
the code that exists is tested.
7.Increased Production Errors: High chances of errors in production.
Practice Questions
Q1. What are the various Testing Levels?
a) Unit Testing
b) System Testing
c) Integration Testing
d) All of the above
Answer: d

Q2. Which of the following testing is also known as white-box testing?


a) Structural testing
b) Error guessing technique
c) Design based testing
d) None of the above
Answer: a

Q3. The white box testing can be proceeded after --------- phase?
e) coding phase
f) designing phase
g) SRS creation
h) installation phase
Answer: a
Bibliography
• https://www.javatpoint.com/white-box-testing
• https://www.tutorialspoint.com/software_testing_dictionary/white_box_tes
ting.htm
• https://www.softwaretestinghelp.com/white-box-testing-techniques-with-e
xample/
• https://www.softwaretestinghelp.com/types-of-software-testing/

• https://www.tutorialspoint.com/software_engineering/software_design_stra
tegies.htm

• https://www.softwaretestinghelp.com/types-of-software-testing/
• https://www.tutorialspoint.com/software_testing_dictionary/alpha_testing.
htm
• https://www.tutorialspoint.com/software_testing_dictionary/validation_test
ing.htm
• https://www.tutorialspoint.com/software_testing_dictionary/acceptance_tes
ting.htm
THANK YOU

OOSE

You might also like