0% found this document useful (0 votes)
9 views3 pages

Bilal Assno.4

Control flow testing is a white-box testing technique that evaluates the execution paths of a program to ensure comprehensive test coverage, focusing on decision points and loops. The process involves creating a control flow graph, identifying test paths, designing test cases, and executing tests to uncover logical errors and unreachable code. An example of its application is in an e-commerce checkout system, where various decision points are tested to ensure proper handling of user actions and payment processing.

Uploaded by

jamalemustafa349
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Bilal Assno.4

Control flow testing is a white-box testing technique that evaluates the execution paths of a program to ensure comprehensive test coverage, focusing on decision points and loops. The process involves creating a control flow graph, identifying test paths, designing test cases, and executing tests to uncover logical errors and unreachable code. An example of its application is in an e-commerce checkout system, where various decision points are tested to ensure proper handling of user actions and payment processing.

Uploaded by

jamalemustafa349
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Department of Information Technology

Faculty of Physical Sciences GC University,


Faisalabad.
Assignment no 4
Name: Muhammad Bilal
Roll Number: 232747
Session: 2023-27
Class: BS (IT) Semester: 4th(Morning)
Course Title: Software Engineering
Instructor: Mam Rabia Shafqat Credit Hour: 3(3-0)

Question:
Explain control flow testing process with advantages and disadvantages. Also provide real world
example in which control flow testing is used and illustrate how control flow testing is used
in this example

Control Flow Testing: Process, Advantages, and Disadvantages


What is Control Flow Testing?
Control flow testing is a white-box testing technique that analyzes the program's flow of
execution by testing various paths through the code. It focuses on decision points, loops, and
conditional branches to ensure complete test coverage.
This method helps detect logical errors, dead code, and untested paths that may cause failures
in real-world scenarios.

Process of Control Flow Testing


1. Create a Control Flow Graph (CFG)
o Represent the program’s logic as a graph where:
 Nodes = Statements or blocks of code
 Edges = Control flow (i.e., transitions between statements)
2. Identify Test Paths
o Extract execution paths to cover loops, conditions, and decision points.
3. Design Test Cases
o Write test cases that ensure each path is executed at least once.
4. Execute Tests & Analyze Results
o Run test cases, identify errors, and debug issues like unreachable code or
incorrect logic.

Advantages and Disadvantages of Control Flow Testing


✅ Advantages
✔ Detects logical errors by covering all branches.
✔ Finds unreachable and redundant code, improving efficiency.
✔ Provides high test coverage, ensuring software reliability.
✔ Helps in early-stage debugging, reducing long-term costs.

❌ Disadvantages
❌ Complex for large systems with many conditions.
❌ Time-consuming, requiring in-depth analysis.
❌ May produce redundant tests for simple programs.
❌ Only useful for white-box testing, requiring access to the source code.

Real-World Example : E-Commerce Checkout System


Scenario
Consider an e-commerce checkout system where a user adds items to the cart and proceeds to
payment. The system has several decision points:
1. Check if the cart is empty.
2. If not, allow the user to proceed to checkout.
3. Validate payment details.
4. If valid, process payment and confirm the order.
5. If payment fails, prompt the user to retry or use another payment method.
6. If retries exceed the limit, cancel the order.

Step 1: Constructing the Control Flow Graph (CFG)


The control flow can be represented as:
 Node 1: User clicks checkout
 Node 2: Check if the cart is empty
o (Yes → Node 6, No → Node 3)
 Node 3: Validate payment details
o (Valid → Node 4, Invalid → Node 5)
 Node 4: Confirm order and process payment
 Node 5: Check if retries exceed the limit
o (Yes → Node 7, No → Node 3)
 Node 6: Show "Cart is empty" message
 Node 7: Cancel order due to payment failure

Step 2: Identifying Test Paths


To test all control flow paths, the following test cases are required:
1. Successful Checkout: 1 → 2 → 3 → 4
2. Cart is Empty: 1 → 2 → 6
3. Payment Failure (Retry Within Limit): 1 → 2 → 3 → 5 → 3 → 4
4. Payment Failure (Retries Exceeded, Order Canceled): 1 → 2 → 3 → 5 → 7

Step 3: Applying Control Flow Testing


 Ensure all test paths are executed.
 Identify missing conditions, such as handling network failures during payment.
 Detect potential issues like allowing checkout with an empty cart.

You might also like