IT242 Software Design and Development

Software Design and DevelopmentUnit 813 min read

Software Testing: Types, Techniques & Strategies

Unit 8 of Software Design and Development covers test planning, test types (unit, integration, system, acceptance), test case design, black-box vs. white-box testing, and automation, with real-world examples from Nepalese apps like eSewa and Daraz, and global tech like Google’s CI/CD pipelines.

TAKEAWAYS:

  • Testing is not just bug-finding: It validates correctness, reliability, and usability through systematic evaluation.
  • Black-box vs. white-box: Black-box tests behavior (e.g., user inputs/outputs), while white-box tests internal logic (e.g., code paths).
  • Test case design: Equivalence partitioning and boundary value analysis reduce test cases while maximizing coverage.
  • Automation saves time: Scripts for regression testing (e.g., Daraz’s order validation) or performance testing (e.g., Ncell’s load handling).
  • Agile vs. V-model: Agile integrates testing early (continuous feedback), while V-model separates phases strictly.
  • Metrics matter: Defect density, test coverage, and mean time to repair (MTTR) measure quality.

1. What is Software Testing?

Software testing is the process of verifying and validating that a software product meets requirements and works as intended. It ensures:

  • Correctness: The software behaves as specified.
  • Reliability: It handles errors gracefully (e.g., eSewa’s transaction retries).
  • Usability: Users can navigate it easily (e.g., Pathao’s ride-booking flow).
  • Performance: It scales under load (e.g., NEPSE’s trading platform during market hours).

Why test?

  • Cost: Fixing bugs early costs 100x less than post-release (IEEE data).
  • Reputation: Poor testing (e.g., a bank app crash) loses user trust.
  • Compliance: Industries like healthcare (e.g., Nepal’s health management systems) require rigorous testing.

1.1 Types of Testing

Testing is classified by scope, level, and technique. Here’s a breakdown:

Unit TestingIntegration TestingSystem TestingAcceptance TestingBy LevelBlack-BoxWhite-BoxGray-BoxBy TechniqueFunctionalNon-Functional (Performance, Security, Usability)By PurposeSoftware Testing Types
Hierarchy of software testing classifications

1.1.1 By Level

Type Focus Example (Nepal) Tools
Unit Testing Individual components (functions, classes) Testing a single calculateLoanEMI() function in a bank app. JUnit, pytest, NUnit
Integration Testing Interaction between modules eSewa’s payment gateway + bank API integration. Postman, SoapUI
System Testing Entire system as a whole Testing Daraz’s checkout flow from cart to delivery. Selenium, LoadRunner
Acceptance Testing User/business approval NTC verifying a new billing system meets regulatory standards. TestRail, Zephyr

1.1.2 By Technique

Technique Approach When to Use Example
Black-Box Test without knowing internal code. UI/UX validation (e.g., Pathao’s app flow). Equivalence partitioning
White-Box Test internal logic (code paths). Debugging a complex algorithm (e.g., NEPSE’s trading match engine). Code coverage tools (JaCoCo)
Gray-Box Partial knowledge of internals. API testing where some backend logic is known. Hybrid of black-box + white-box

1.2 Test Case Design Techniques

Goal: Design minimal yet effective test cases to catch defects.

1.2.1 Equivalence Partitioning

Divide input data into partitions where each partition is expected to behave the same. Test one value per partition.

Example: Testing a loan eligibility function in a bank app.

  • Valid partitions:
    • Income ≥ 50,000 NPR (should approve).
    • Income < 50,000 NPR (should reject).
  • Invalid partitions:
    • Negative income (edge case).
    • Non-numeric input (e.g., "abc").

Test Cases:

Partition Test Input Expected Output
Valid income (high) 60,000 NPR Loan approved
Valid income (low) 45,000 NPR Loan rejected
Invalid (negative) -10,000 NPR Error: "Invalid input"
Invalid (non-numeric) "fifty thousand" Error: "Enter a number"

1.2.2 Boundary Value Analysis

Test boundaries of input ranges (where errors often occur).

  • Example: A hotel booking system where rooms are booked for 1–30 days.
    • Test cases: 0, 1, 30, 31 days.
    • Expected: 0 and 31 should fail; 1 and 30 should succeed.

2. Black-Box vs. White-Box Testing

Aspect Black-Box Testing White-Box Testing
Focus Input/output behavior Internal code structure
Tester’s Knowledge No code knowledge needed Requires code understanding
Techniques Equivalence partitioning, boundary value Statement coverage, branch coverage
Example Testing WhatsApp’s message delivery Testing a sorting algorithm’s edge cases
Tools Selenium, Postman JaCoCo, CodeSonar
When to Use UI, API, system testing Unit testing, debugging
Black-BoxExternal ViewGray-BoxPartial InternalWhite-BoxFull Internal
Testing visibility spectrum

3. Test Automation

Manual testing is slow and error-prone. Automation:

  • Saves time: Run regression tests overnight (e.g., Daraz’s daily sales checks).
  • Improves accuracy: No human fatigue.
  • Supports CI/CD: Tools like Jenkins integrate tests into development pipelines.

3.1 When to Automate?

Scenario Automate? Reason
Repetitive regression tests ✅ Yes Example: Ncell’s app updates after patches.
Performance/load testing ✅ Yes Example: eSewa during Diwali sales.
Exploratory testing ❌ No Requires human creativity.
One-time smoke tests ❌ No Not cost-effective.
Tool Type Use Case
Selenium UI Automation Testing web apps (e.g., Daraz checkout).
JUnit Unit Testing Java-based unit tests.
Postman API Testing Testing eSewa’s payment API.
Jenkins CI/CD Pipeline Automating test suites in agile teams.

4. Testing in Software Development Models

How testing fits into SDLC models:

4.1 V-Model

  • Waterfall approach: Testing phases mirror development phases.
  • Pros: Structured, good for regulated industries (e.g., NTC’s billing systems).
  • Cons: Late defect detection.

4.2 Agile Model

  • Testing is continuous: Developers write tests alongside code (TDD).
  • Pros: Early defect detection, faster feedback.
  • Cons: Requires discipline; less documentation.

Example: Google’s Test-Driven Development (TDD) for YouTube’s recommendation engine.

  1. Write a failing test for a new feature.
  2. Write minimal code to pass the test.
  3. Refactor and repeat.

5. Non-Functional Testing

Ensures quality attributes beyond functionality:

Type Description Example (Nepal) Tools
Performance Speed, scalability, load handling NEPSE’s platform during market crashes. JMeter, LoadRunner
Security Vulnerability testing Khalti’s PCI-DSS compliance checks. OWASP ZAP, Burp Suite
Usability User experience (UI/UX) Pathao’s app navigation for elderly users. UserTesting.com
Compatibility Cross-browser/device testing eSewa working on Android 8+ and iOS 14+. BrowserStack

In the Real World

  1. eSewa’s Transaction Testing

    • What’s tested: Black-box testing for payment flows (e.g., "Transfer 500 NPR to a friend").
    • How: Equivalence partitioning for amounts (valid/invalid), boundary values (0.01 NPR), and error cases (insufficient balance).
    • Automation: Selenium scripts verify the UI; Postman tests the API.
  2. Daraz’s Order Queue

    • What’s tested: System testing for race conditions (multiple users checking out simultaneously).
    • How: Load testing with 10,000 concurrent users to simulate Black Friday.
    • Tool: JMeter simulates traffic; Jenkins triggers tests post-deployment.
  3. Ncell’s Network Stability

    • What’s tested: Performance testing for call drops during peak hours (e.g., 7–9 PM).
    • How: Inject 50,000 calls/minute; measure drop rate and latency.
    • Tool: LoadRunner monitors KPIs like mean time between failures (MTBF).
  4. Nepal Rastra Bank’s Core Banking System

    • What’s tested: Security testing for SQL injection and data breaches.
    • How: Penetration testing by ethical hackers; OWASP ZAP scans for vulnerabilities.
    • Compliance: Must pass ISO 27001 audits.

6. Test Metrics

Quantify testing effectiveness:

Metric Formula Example
Defect Density Total defects / Size (LOC or function points) 5 defects per 1,000 lines of code.
Test Coverage (Tested requirements / Total requirements) × 100 95% branch coverage in a loan app.
Mean Time to Repair (MTTR) Total repair time / Number of defects 2 hours to fix a critical bug in eSewa.
Defect Slip-Through Rate (Defects in production / Total defects found) × 100 5% of bugs escaped testing in Ncell’s app.

7. Common Testing Pitfalls

  • Over-testing: Wasting resources on trivial cases (e.g., testing "1+1=2" in a calculator).
  • Under-testing: Skipping edge cases (e.g., not testing empty carts in Daraz).
  • Ignoring non-functional tests: Assuming "if it works, it’s fast" (e.g., a slow NEPSE login page).
  • No test automation: Manual regression testing is unscalable for apps like Pathao.

Exam Tip

What Examiners Look For

  1. Definitions: Know the difference between unit vs. integration testing, black-box vs. white-box.
  2. Examples: Relate concepts to Nepalese apps (e.g., "How would you test eSewa’s payment flow?").
  3. Diagrams: Draw V-model vs. Agile testing phases or equivalence partitioning tables.
  4. Tools: Name at least 2 tools for each test type (e.g., Selenium for UI, JMeter for load).
  5. Metrics: Calculate defect density or test coverage from given data.
  6. Real-world scenarios: Explain how automation helps Daraz or how boundary testing catches bugs in Ncell’s billing.

High-Scoring Answers Include:

  • Step-by-step test case design (e.g., "For a login system, I’d test: valid credentials, wrong password, empty fields").
  • Pros/cons comparisons (e.g., "V-model is rigid but thorough; Agile is flexible but requires discipline").
  • Visuals: Always sketch a test matrix or flowchart if the question asks for a plan.

Practice Question

Scenario: You’re testing a food delivery app (like Pathao) for a TU exam. Design 3 black-box test cases using equivalence partitioning and boundary value analysis for the "Add to Cart" feature.

Solution Outline:

  1. Valid partitions:
    • Quantity = 1 (minimum).
    • Quantity = 5 (normal).
  2. Invalid partitions:
    • Quantity = 0 (edge case).
    • Quantity = 101 (max exceeded).
  3. Boundary values:
    • Quantity = 0 (should show "Add at least 1 item").
    • Quantity = 100 (max allowed; should accept).
    • Quantity = 101 (should reject with "Max 100 items").

Test Cases:

Test ID Input (Quantity) Expected Output
TC01 1 Item added to cart.
TC02 5 Item added to cart.
TC03 0 Error: "Quantity cannot be zero."
TC04 100 Item added to cart.
TC05 101 Error: "Exceeds maximum quantity."

flowchart TD
    A["Unit Tests"] -->|"Most Frequent"| B["Integration Tests"]
    B -->|"Less Frequent"| C["UI/Acceptance Tests"]
    caption Testing Pyramid (Adapted from Mike Wacker, Public Domain)
A pyramid diagram showing unit tests at the base (most frequent), integration tests in the middle, and UI/acceptance tests at the top (least frequent). (Image: Mike Wacker, Public domain, via Wikimedia Commons)

Based on the TU BIM syllabus for Software Design and Development (IT242), unit 8.

Discussion

Loading…