ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Software Testing & Quality Assurance
    COMP4125
    Progress0 / 9 topics
    Topics
    1. Testing techniques2. Black Box testing techniques3. White Box testing techniques4. Grey Box testing techniques5. Quality Assurance planning and execution6. Automated testing: constructing a framework7. Scripting techniques for automated testing8. Generating test data9. Generating test reports
    COMP4125›White Box testing techniques
    Software Testing & Quality AssuranceTopic 3 of 9

    White Box testing techniques

    4 minread
    603words
    Beginnerlevel

    📘 WHITE BOX TESTING TECHNIQUES

    ✅ 1. What is White Box Testing?

    Definition: White Box Testing is a technique where the tester has full knowledge of the internal code, structure, and logic of the program.

    👉 Simple meaning: You test how the program works internally (code logic).


    🎯 Key Features

    • Requires programming knowledge

    • Tests internal structure

    • Also called:

      • Structural Testing
      • Glass Box Testing
      • Clear Box Testing

    📦 Basic Working

    Input → Code Logic → Output
             ↑
         Tested here
    

    👉 Focus is on code execution paths


    🔑 MAIN WHITE BOX TESTING TECHNIQUES


    🔵 1. STATEMENT COVERAGE

    📌 Definition:

    Ensures that every line (statement) of code is executed at least once.


    🪜 Steps:

    1. Identify all statements in code
    2. Design test cases to execute each statement
    3. Measure coverage

    📊 Example:

    if (x > 0)
       print("Positive");
    

    👉 Test case:

    • x = 5 → executes the statement

    📐 Formula:

    Statement Coverage = (Executed Statements / Total Statements) × 100%
    

    🎯 Key Point:

    • Minimum level of testing
    • Does NOT guarantee full logic testing

    🟢 2. BRANCH COVERAGE (Decision Coverage)

    📌 Definition:

    Ensures that each decision (true/false branch) is executed.


    📊 Example:

    if (x > 0)
       print("Positive");
    else
       print("Negative");
    

    👉 Test cases:

    • x = 5 → TRUE branch
    • x = -2 → FALSE branch

    📐 Formula:

    Branch Coverage = (Executed Branches / Total Branches) × 100%
    

    🎯 Key Point:

    • More powerful than statement coverage
    • Covers all decision outcomes

    👉 🔥 Frequently asked!


    🟡 3. PATH COVERAGE

    📌 Definition:

    Ensures that all possible execution paths in the program are tested.


    📊 Example:

    if (x > 0)
       print("Positive");
    if (y > 0)
       print("Y Positive");
    

    👉 Possible paths:

    1. x>0, y>0
    2. x>0, y≤0
    3. x≤0, y>0
    4. x≤0, y≤0

    🎯 Key Point:

    • Provides maximum coverage
    • Difficult for large programs

    👉 🔥 Very important for exams!


    🟣 4. LOOP TESTING

    📌 Definition:

    Tests the correctness of loops (for, while, do-while).


    🪜 Test Cases for Loop:

    • 0 iterations
    • 1 iteration
    • 2 iterations
    • Maximum iterations

    📊 Example:

    for(i=0; i<n; i++)
       print(i);
    

    👉 Test with:

    • n = 0
    • n = 1
    • n = many

    🎯 Key Point:

    • Helps detect infinite loops
    • Ensures loop correctness

    🟠 5. DATA FLOW TESTING

    📌 Definition:

    Focuses on how variables are defined, used, and modified in the program.


    🔍 Key Concepts:

    • Definition (value assigned)
    • Use (value used)
    • Kill (value removed)

    📊 Example:

    int x = 5;   // define
    print(x);    // use
    

    🎯 Key Point:

    • Finds errors like:

      • Unused variables
      • Undefined variables

    🔴 6. CONDITION COVERAGE

    📌 Definition:

    Tests each individual condition in a decision.


    📊 Example:

    if (x > 0 && y > 0)
    

    👉 Conditions:

    • x > 0
    • y > 0

    Test cases:

    • Both true
    • One false
    • Both false

    🎯 Key Point:

    • More detailed than branch coverage

    🧠 COVERAGE HIERARCHY (Important!)

    Statement < Branch < Condition < Path
    

    👉 Path coverage is strongest.


    ⚖️ ADVANTAGES & DISADVANTAGES

    ✅ Advantages:

    • Finds hidden errors
    • Improves code quality
    • Ensures logic correctness

    ❌ Disadvantages:

    • Requires programming knowledge
    • Time-consuming
    • Not suitable for large systems fully

    🔥 FREQUENTLY ASKED EXAM POINTS

    ✔ Define White Box Testing ✔ Statement vs Branch Coverage ✔ Path Coverage explanation ✔ Loop testing cases ✔ Coverage formulas ✔ Coverage hierarchy


    📊 QUICK REVISION TABLE

    Technique What it Tests Key Idea
    Statement Coverage All lines Each statement executed
    Branch Coverage Decisions True/False paths
    Path Coverage All paths Complete execution
    Loop Testing Loops Iterations
    Data Flow Testing Variables Define & use
    Condition Coverage Conditions Each condition

    🎯 FINAL SUMMARY

    • White Box Testing focuses on internal code logic

    • Requires programming knowledge

    • Key techniques:

      • Statement Coverage
      • Branch Coverage
      • Path Coverage
      • Loop Testing
      • Data Flow Testing
      • Condition Coverage
    • Branch & Path coverage are most important for exams


    Previous topic 2
    Black Box testing techniques
    Next topic 4
    Grey Box testing techniques

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time4 min
      Word count603
      Code examples0
      DifficultyBeginner