Session 12

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 11

Department of CSE-Honors

COURSE NAME – SOFTWARE


VERIFICATION AND VALIDATION
COURSE CODE – 22SMD3101R
Topic:
White Box testing Techniques

Session - 12
WHITE BOX TESTING

White box testing, also known as clear box testing or structural testing, involves examining the internal
workings of a software application to ensure that all parts of the code are functioning correctly.
Following are the steps that are taken into consideration while performing white box testing:
• Verification of security holes in source code
• Testing of any broken or incomplete path
• To verify the flow of structure as mentioned in the software requirement document
• To check the conditionality of all loops and the overall functionality of the software
• To check if all the expected outcomes are met
• Line-by-line verification of code
The above-mentioned steps can be executed at each level of testing i.e Unit, Integration and System
Testing.
2
WHITE BOX TESTING TECHNIQUES
Here are some common techniques used in white box testing:

• Unit Testing • Control Flow Testing

• Integration Testing • Path Testing

• Code Coverage Analysis • Loop Testing

• Statement Coverage • Data Flow testing

• Branch Coverage • Mutation Testing


• Path Coverage

3
1. Unit Testing
• Purpose: To test individual components or functions in isolation.
• Technique: Writing test cases for specific functions or methods to verify that they
work correctly on their own.
2. Integration Testing
• Purpose: To test the interaction between integrated components or systems.
• Technique: Ensuring that different modules or services interact as expected and data
flows correctly between them.
3. Code Coverage Analysis
• Purpose: To measure the extent to which the source code is executed during testing.
• Technique: Tools and metrics like line coverage, branch coverage, and path coverage
help identify which parts of the code are exercised by the test cases

4
4. Control Flow Testing
 Purpose: To test the execution paths within the code.
 Technique: Creating test cases that cover all possible paths through the control flow
of the program, including decision points, loops, and branches.
5. Data Flow Testing
 Purpose: To focus on the flow of data through the program.
 Technique: Verifying that data is correctly defined, used, and destroyed as it moves
through various operations and functions.
6. Path Testing
 Purpose: To ensure all possible paths through a program are tested.
 Technique: Identifying and testing different execution paths to ensure complete
coverage of all possible scenarios.
5
7. Condition Testing
 Purpose: To validate that each condition in the code behaves correctly.
 Technique: Ensuring that all possible boolean conditions in the code are tested, including
true and false evaluations.
8. Loop Testing
 Purpose: To test the functionality of loops in the code.
 Technique: Creating test cases that execute loops under various conditions, including
zero, one, and multiple iterations.
9. Mutation Testing
 Purpose: To evaluate the quality of test cases by introducing small changes (mutations)
to the code.
 Technique: Generating mutants (modified versions of the code) to see if the existing test
cases can detect these changes.
6
White Box Testing Example

def Printme(a, b):


result = a + b
if result > 0:
print("Positive", result)
else:
print("Negative", result)
In this python code, Printme is a function that takes two inputs, adds them, and checks
whether the result is positive or negative. If the result is positive, it prints “Positive”. If the
result is not positive (i.e., zero or negative), it prints “Negative” along with it.

7
The goal of White Box Testing here is to verify all the decision branches (the if-else
condition) in the code.
To exercise the statements in above python code, we would create the following test
cases:
•Test Case 1: a = 1, b = 1
• This would test the “Positive” branch of the if-else condition.
•Test Case 2: a = -1, b = -3
• This would test the “Negative” branch of the if-else condition.

8
Tools and Frameworks used to perform White Box Testing
Code Coverage Tools
•JUnit: A widely-used framework for unit testing in Java. It integrates with various code
coverage tools to measure how much of the code is tested.
•NUnit: Similar to JUnit but for .NET applications. It supports various code coverage tools.
•TestNG: Another testing framework for Java that supports parallel test execution and
integrates with code coverage tools.
Code Analysis Tool
•Code Quality: BrowserStack Code Quality helps check the code and ensure it follows all
the required standards.

9
Key Benefits of White Box Testing:
 Detailed Testing: Allows for a thorough understanding of the internal logic and
structure.
 Early Detection: Helps identify issues in the code at an early stage.
 Optimized Coverage: Ensures that all paths and conditions are tested, improving
test coverage.
Challenges:
 Complexity: Requires knowledge of the internal code, which can be complex and
time-consuming.
 Maintenance: Test cases may need frequent updates with changes in the codebase.

10
THANK YOU

Team – software verification and validation

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy