BIT302 Software Engineering

Software EngineeringUnit 611 min read

Software Testing & Quality Assurance

Unit 6 of Software Engineering: Explores testing methodologies (black-box, white-box, unit, integration, system), quality assurance frameworks, defect management, and real-world testing tools like Selenium and JUnit, with worked examples from eSewa’s payment validation and Daraz’s order processing.

TAKEAWAYS:

  • Testing is the systematic process of validating software against requirements, while quality assurance (QA) ensures processes prevent defects.
  • Black-box testing focuses on inputs/outputs (e.g., eSewa’s transaction validation), while white-box testing inspects code logic (e.g., Daraz’s inventory algorithms).
  • Unit testing (e.g., Pathao’s ride-matching logic) isolates components, integration testing checks interactions (e.g., NTC’s billing system modules), and system testing verifies end-to-end functionality (e.g., Ncell’s call routing).
  • Defect management uses tools like JIRA to track bugs, while test automation (e.g., Selenium for eSewa’s UI) reduces manual effort.
  • Quality metrics (e.g., defect density, test coverage) quantify reliability, and ISO/IEC 25010 standards define software quality attributes.
  • Agile testing (e.g., sprint-based QA in Daraz) contrasts with waterfall’s late-stage testing, emphasizing continuous feedback.

1. Introduction to Software Testing

Software testing is the process of executing a program with the intent of finding errors. It ensures software meets specified requirements, operates as intended, and handles edge cases gracefully.

Why Test?

  • Bug detection: Catches logical, syntax, or interface errors early.
  • Performance validation: Checks speed, scalability, and resource usage (e.g., NTC’s network latency during peak hours).
  • Security testing: Identifies vulnerabilities (e.g., SQL injection in eSewa’s payment gateway).
  • User experience (UX): Ensures usability and accessibility (e.g., Pathao’s app for visually impaired users).

Testing vs. Quality Assurance (QA)

Aspect Software Testing Quality Assurance (QA)
Focus Detects defects in software. Prevents defects via processes, standards.
When? Post-development (or during Agile sprints). Throughout the software lifecycle.
Tools Test cases, scripts (e.g., Selenium). Checklists, ISO standards, code reviews.
Example Running eSewa’s payment test cases. Implementing CI/CD pipelines for Daraz orders.
TestingBugsVerificationCorrectnessValidationUser NeedsQuality AssuranceProcess
Differentiating testing, verification, validation, and QA in software development.

2. Types of Software Testing

Testing is classified based on scope, level, and approach:

A. Based on Scope

  1. Unit Testing

    • Tests individual components (functions, classes, modules).
    • Example: Testing Pathao’s ride-matching algorithm to ensure optimal driver allocation.
    • Tools: JUnit (Java), pytest (Python), Mocha (JavaScript).
  2. Integration Testing

    • Tests interactions between modules (e.g., NTC’s billing system + customer portal).
    • Example: Verifying Ncell’s call routing integrates with SMS alerts.
  3. System Testing

    • Tests the entire system against requirements (e.g., Daraz’s checkout flow).
    • Subtypes:
      • Functional Testing: Validates features (e.g., eSewa’s refund process).
      • Non-Functional Testing:
        • Performance: Load testing for NEPSE’s trading platform.
        • Security: Penetration testing for Khalti’s API.
        • Usability: Testing NTC’s mobile app for elderly users.
  4. Acceptance Testing

    • User/Client validates if the system meets business needs (e.g., bank approving a new loan system).

B. Based on Approach

  1. Black-Box Testing

    • No knowledge of internal code; tests based on requirements/specs.
    • Example: Testing eSewa’s payment gateway by sending fake transactions.
    • Techniques:
      • Equivalence Partitioning: Group inputs into valid/invalid ranges (e.g., age fields in Daraz sign-up).
      • Boundary Value Analysis: Tests edge values (e.g., minimum/maximum order quantity).
  2. White-Box Testing

    • Inspects internal code/logic (e.g., reviewing Daraz’s inventory update scripts).
    • Techniques:
      • Statement Coverage: Ensures every line of code is executed.
      • Path Coverage: Tests all possible code paths (e.g., NTC’s failover routes).

C. Based on Timing

  1. Static Testing
    • No execution; reviews code/documents (e.g., peer reviews for Ncell’s app updates).
  2. Dynamic Testing
    • Runs the software (e.g., automated tests for Pathao’s surge pricing).

3. Test Design Techniques

A. Equivalence Partitioning

  • Divides input data into equivalent classes (valid/invalid).
  • Example: Testing Daraz’s discount codes:
    • Valid: "DARAZ10" (10% off).
    • Invalid: "DARAZ100" (invalid format).

B. Boundary Value Analysis

  • Tests boundaries of input ranges.
  • Example: NEPSE’s trading platform:
    • Minimum share price: ₹1.
    • Maximum order quantity: 1,000 shares.

C. Decision Table Testing

  • Tests combinations of conditions (e.g., eSewa’s fraud detection rules).
Condition 1 (Amount) Condition 2 (Time) Expected Action
≤₹10,000 Daytime Approve
>₹10,000 Nighttime Flag for manual review

4. Test Cases and Scripts

A test case is a set of inputs, expected outputs, and steps to verify behavior.

Example: eSewa Payment Test Case

gantt
    title: eSewa Payment Test Case
    section: Test Steps
    User logs in          :a1, 2d
    Selects "Pay Bill"   :a2, 1d, after a1
    Enters amount (₹500) :a3, 1d, after a2
    Clicks "Pay"          :a4, 1d, after a3
    System shows "Success":a5, 1d, after a4

Automated Testing

  • Tools: Selenium (UI), Postman (API), JMeter (performance).
  • Example: Daraz uses Selenium to automate order processing tests.

5. Defect Management

Defects are discrepancies between expected and actual behavior.

Defect Life Cycle

stateDiagram-v2
    [*] --> Opened
    Opened --> Assigned
    Assigned --> In Progress
    In Progress --> Verified
    Verified --> Fixed
    Fixed --> Reopened
    Reopened --> Closed
    Closed --> [*]

Example: Ncell’s Call Drop Bug

  1. Reported: Users complain of call drops in Kathmandu.
  2. Assigned: Network team investigates.
  3. Fixed: Upgrades base stations.
  4. Verified: Tests confirm 99% uptime.

6. Quality Assurance (QA) Standards

ISO/IEC 25010: Software Quality Model

Defines 8 quality characteristics:

  1. Functional Suitability (e.g., eSewa’s multi-bank support).
  2. Performance Efficiency (e.g., NEPSE’s trading speed).
  3. Compatibility (e.g., Pathao’s Android/iOS support).
  4. Security (e.g., Khalti’s encryption).
  5. Usability (e.g., NTC’s app for visually impaired).
  6. Reliability (e.g., Ncell’s 99.9% call success rate).
  7. Maintainability (e.g., Daraz’s modular codebase).
  8. Portability (e.g., eSewa’s cross-device access).

7. Real-World Examples

1. eSewa’s Payment Validation (Black-Box Testing)

  • Idea: Uses equivalence partitioning to test transaction amounts.
  • Example:
    • Valid: ₹100, ₹999.99.
    • Invalid: ₹-50, ₹1,000,000 (exceeds limit).

2. Daraz’s Order Queue (Integration Testing)

  • Idea: Tests inventory system + payment gateway interaction.
  • Worked Example:
    • User adds items to cart → Payment succeeds → Inventory deducts stock.
    • Bug: If payment fails, inventory should not deduct (race condition).

3. NTC’s Network Failover (System Testing)

  • Idea: Disaster recovery testing ensures calls route to backup towers.
  • Test Case:
    • Simulate tower failure → Verify calls redirect to nearest tower.

8. Exam Tip

  • Focus Areas:
    • Compare black-box vs. white-box testing (table format).
    • Explain unit vs. system testing with real examples (e.g., Pathao’s app vs. NTC’s network).
    • Draw a defect life cycle diagram (stateDiagram-v2).
    • Relate testing to Agile (continuous testing in sprints) vs. Waterfall (late-stage testing).
    • Calculate test coverage (e.g., "80% of unit tests passed").
  • Common Pitfalls:
    • Forgetting non-functional testing (performance, security).
    • Overlooking test automation tools (Selenium, JUnit).
    • Not linking ISO/IEC standards to real-world examples (e.g., NEPSE’s reliability).

9. In the Real World

  1. eSewa

    • Idea: Uses white-box testing to audit its fraud detection algorithms.
    • How: Developers review code paths for anomalies (e.g., duplicate transactions).
  2. Daraz

    • Idea: Integration testing between warehouse and delivery systems.
    • Example: If an order is "out of stock," the system automatically cancels it before reaching the warehouse.
  3. Ncell

    • Idea: Performance testing for 5G rollout.
    • Worked Example: Simulates 10,000 users in Kathmandu to test network stability.

10. Visuals

A. Software Testing Pyramid

B. Defect Severity Matrix

Severity Description Example
Critical System crash Ncell’s call drop during peak
Major Major feature failure eSewa’s refund button broken
Minor Cosmetic issue Daraz’s font size too small
Trivial Documentation typo NEPSE’s manual has a grammar error

11. Worked Example: Loan Interest Calculation (Banking)

Scenario: A bank uses white-box testing to verify its loan interest formula.

Formula:

Where:

  • = Principal (₹10,000)
  • = Annual rate (5% = 0.05)
  • = Time (1 year)

Test Cases:

Test Case Input (P, r, t) Expected Output Actual Output Result
Valid (10000, 0.05, 1) ₹500 ₹500 Pass
Boundary (0, 0.05, 1) ₹0 ₹0 Pass
Invalid (10000, -0.05, 1) Error ₹-500 Fail

Fix: Add validation for negative rates.


12. Key Takeaways for Exams

  • Memorize: Definitions of unit/system/acceptance testing.
  • Draw: Test pyramids, defect life cycles, and ISO/IEC quality attributes.
  • Apply: Relate testing to real apps (eSewa, Daraz, Ncell).
  • Calculate: Test coverage percentages (e.g., "60% of functions tested").
  • Compare: Black-box vs. white-box, Agile vs. Waterfall testing.

Based on the TU BIT syllabus for Software Engineering (BIT302), unit 6.

Discussion

Loading…