0% found this document useful (0 votes)
6 views4 pages

5124white Box Testing-2

Uploaded by

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

5124white Box Testing-2

Uploaded by

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

Control flow testing is a white-box testing technique that focuses on the logical flow of a

program by using the control flow graph (CFG) to represent paths of execution. Each node in
the CFG represents a block of code, and edges represent the control flow between these
blocks.

For a Library Management System (LMS), here’s how we can break down various
components and perform control flow testing. Below, I’ll outline the approach and provide some
control flow test cases for key modules such as user login, book search, borrowing books,
returning books, and fines.

1. Identify Components for Testing

Key modules of a Library Management System could include:

● User Login
● Book Search
● Borrowing Books
● Returning Books
● Fine Calculation
● Adding/Deleting Books (Admin)

Each of these modules will have different logical paths to test.

2. Create Control Flow Graph (CFG)

Each of the components below would be converted into a control flow graph where each
condition, loop, and branch is represented.

Here is the control flow for some key modules:

Module 1: User Login

Description: Users enter their credentials, which are validated against the database.

Control Flow:

1. Enter Username (Node 1)


2. Enter Password (Node 2)
3. Verify credentials (Decision Node 3: valid/invalid)
○ If valid (Node 4): Login successful
○ If invalid (Node 5): Display error message
4. End (Exit Node)
Test Cases:

Test Case ID Path Expected Outcome

TC1 1 → 2 → 3 (valid) → 4 Login successful

Error message: "Invalid


TC2 1 → 2 → 3 (invalid) → 5 → 1 credentials"

TC3 1 → 2 → 3 (invalid) → 5 → Exit User exits after failed attempt

Module 2: Book Search

Description: Users search for books by entering the title or author.

Control Flow:

1. Enter search criteria (Node 1)


2. Check if criteria is valid (Decision Node 2: valid/invalid)
○ If valid (Node 3): Search for books
○ If invalid (Node 4): Display error message
3. If books found (Decision Node 5: found/not found)
○ If found (Node 6): Display list of books
○ If not found (Node 7): Display message "No books found"
4. End (Exit Node)

Test Cases:

Test Case Expected


ID Path Outcome

TC4 1 → 2 (valid) → 3 → 5 (found) → 6 Display list of books

1 → 2 (valid) → 3 → 5 (not found) → Display message:


TC5 7 "No books found"

Error message:
"Invalid search
TC6 1 → 2 (invalid) → 4 → 1 criteria"
Module 3: Borrowing Books

Description: The user selects a book and attempts to borrow it, provided it is available.

Control Flow:

1. Select book to borrow (Node 1)


2. Check book availability (Decision Node 2: available/not available)
○ If available (Node 3): Proceed to borrow
○ If not available (Node 4): Display "Book not available" message
3. Check if user has outstanding fines (Decision Node 5: fine/no fine)
○ If no fine (Node 6): Complete borrowing process
○ If fine (Node 7): Display "Pay fine first" message
4. End (Exit Node)

Test Cases:

Test Case
ID Path Expected Outcome

TC7 1 → 2 (available) → 3 → 5 (no fine) → 6 Book borrowed successfully

Display message: "Pay fine


TC8 1 → 2 (available) → 3 → 5 (fine) → 7 first"

Display message: "Book not


TC9 1 → 2 (not available) → 4 → 1 available"
3. Apply Basis Path Testing

The next step is to apply Basis Path Testing to ensure all independent paths are covered.
Here's how to do it:

1. Draw the CFG for each module as explained above.

To indicate a Sequence: To indicate "IF-THEN-ELSE":

To indicate a "WHILE" Loop: To indicate a "CASE" Statement:

2. Calculate the Cyclomatic Complexity using the formula:


Cyclomatic Complexity=E−N+2P
Where:
○ E = Number of edges
○ N = Number of nodes
○ P = Number of connected components (usually 1 if it's one connected graph)
3. Identify all independent paths: Using the control flow graph, identify all possible paths
(e.g., from start to finish) covering every edge and node.
4. Design Test Cases for Each Path: Ensure there is at least one test case for every
identified path to ensure maximum coverage.

You might also like