Software Design and DevelopmentUnit 818 min read
Software Testing: Types, Techniques & Strategies
Unit 8 of Software Design and Development covers the fundamentals of software testing, including test types (unit, integration, system, acceptance), test techniques (black-box, white-box, grey-box), test case design, and test automation, with real-world applications and exam-focused insights.
TAKEAWAYS:
- Software testing ensures software meets requirements, identifies defects early, and improves quality through systematic validation and verification.
- Test types (unit, integration, system, acceptance) target different levels of software granularity, each requiring distinct strategies.
- Test techniques like black-box (input/output-based) and white-box (code structure-based) are chosen based on accessibility to system internals.
- Test case design follows standards (e.g., equivalence partitioning, boundary value analysis) to maximize defect detection with minimal effort.
- Automation (e.g., Selenium, JUnit) speeds up regression testing but requires careful script maintenance and tool selection.
- Real-world applications (e.g., eSewa’s transaction validation, Daraz’s order processing) rely on rigorous testing to ensure reliability and user trust.
1. Introduction to Software Testing
Software testing is a quality assurance process that evaluates whether software behaves as expected. It involves executing a program with specific inputs and comparing actual outputs to expected results. Testing is not just about finding bugs—it also validates requirements, improves usability, and ensures compliance with standards.
Why is Testing Important?
- Defect Detection: Identifies errors early, reducing costs (fixing a bug in design costs 100x less than in production).
- Quality Assurance: Ensures software meets user and business needs.
- Risk Mitigation: Prevents failures in critical systems (e.g., banking, healthcare).
- Compliance: Meets industry standards (e.g., ISO/IEC 25010 for software quality).
Testing vs. Debugging
| Testing | Debugging |
|---|---|
| Verifies if software works correctly. | Finds and fixes defects. |
| Performed by testers/QA engineers. | Done by developers. |
| Uses test cases and scenarios. | Uses logs, breakpoints, and code analysis. |
| Goal: Validate correctness. | Goal: Remove errors. |
2. Types of Software Testing
Testing is classified based on scope, level, and technique. Below are the key categories:
2.1 By Test Level
sequenceDiagram
participant User
participant Daraz_API
participant Inventory_DB
participant Notification_Service
User->>Daraz_API: Place Order (Item ID: 123)
Daraz_API->>Inventory_DB: Check Stock
Inventory_DB-->>Daraz_API: Stock Available
Daraz_API->>Notification_Service: Send Confirmation
Notification_Service-->>User: Order Confirmed
alt Inventory Unavailable
Daraz_API-->>User: Out of Stock
endSequence diagram for integration testing of Daraz’s order flow (top-down approach)a) Unit Testing
- Tests individual components (functions, methods, classes) in isolation.
- Example: Testing a
calculateDiscount()function in an e-commerce app. - Tools: JUnit (Java), pytest (Python), NUnit (.NET).
- Worked Example:
Suppose a bank’s
calculateInterest()function is tested with inputs:- Principal = 100,000; Rate = 5%; Time = 1 year → Expected: 5,000.
- Edge case: Principal = 0 → Expected: 0 (no interest).
b) Integration Testing
- Tests interactions between integrated units (e.g., database + API).
- Example: Testing if Daraz’s order processing module correctly updates inventory and sends notifications.
- Types:
- Big Bang: All units integrated at once (risky).
- Incremental: Step-by-step integration (e.g., top-down, bottom-up).
c) System Testing
- Tests the entire system against functional and non-functional requirements.
- Example: Testing eSewa’s end-to-end transaction flow (login → payment → confirmation).
- Subtypes:
- Functional Testing: Validates features (e.g., user login).
- Non-Functional Testing: Performance, security, usability.
d) Acceptance Testing
- Performed by end-users or clients to validate if the system meets business needs.
- Example: NTC testing a new billing software with sample users before full deployment.
- Types:
- User Acceptance Testing (UAT): Users test in a real-world scenario.
- Operational Acceptance Testing (OAT): IT team checks deployment readiness.
2.2 By Test Technique
a) Black-Box Testing
- Tests without knowing internal code (focuses on inputs/outputs).
- Techniques:
- Equivalence Partitioning: Divides inputs into groups (e.g., valid/invalid emails).
- Boundary Value Analysis: Tests edge cases (e.g., max/min limits).
- Example: Testing WhatsApp’s login with invalid passwords (e.g., empty field, special characters).
b) White-Box Testing
- Tests internal logic (requires code access).
- Techniques:
- Statement Coverage: Ensures every line is executed.
- Branch Coverage: Tests all decision paths (e.g.,
if-elseconditions).
- Example: Checking if a loop in Pathao’s ride-matching algorithm terminates correctly.
c) Grey-Box Testing
- Combines black-box and white-box (partial knowledge of internals).
- Example: Testing a bank’s ATM system where testers know some backend logic but not all.
2.3 By Test Type
| Test Type | Description | Example |
|---|---|---|
| Performance Testing | Checks speed, scalability, stability. | Testing YouTube’s buffer time under high traffic. |
| Security Testing | Identifies vulnerabilities (e.g., SQL injection). | Penetration testing on Daraz’s checkout page. |
| Usability Testing | Evaluates user-friendliness. | Testing Ncell’s app for elderly users. |
| Regression Testing | Ensures new changes don’t break existing features. | Retesting eSewa after a new update. |
3. Test Case Design
A test case is a set of inputs, execution conditions, and expected results designed to validate a specific feature.
stateDiagram-v2
[*] --> Valid_Credentials
Valid_Credentials --> Dashboard
Invalid_Credentials --> Error_Page
Error_Page --> [*]
Error_Page --> Retry
Retry --> Valid_Credentials
Retry --> Invalid_CredentialsSteps to Design Test Cases
- Identify Test Objectives: What is being tested? (e.g., login functionality).
- Define Test Inputs: Valid and invalid data (e.g., correct/incorrect email formats).
- Specify Expected Results: What should happen? (e.g., "System should show ‘Invalid email’").
- Execute and Compare: Run the test and verify actual vs. expected results.
Example: Testing a Login System
| Test Case ID | Description | Input Data | Expected Result |
|---|---|---|---|
| TC001 | Valid credentials | Username: user1, Password: pass123 |
Login successful, dashboard loads. |
| TC002 | Empty password | Username: user1, Password: `` |
Error: "Password cannot be empty." |
| TC003 | Incorrect password | Username: user1, Password: wrongpass |
Error: "Invalid credentials." |
Techniques for Test Case Design
| Technique | Description | Example |
|---|---|---|
| Equivalence Partitioning | Divides inputs into equivalence classes. | Valid emails: user@example.com; Invalid: user@.com. |
| Boundary Value Analysis | Tests values at boundaries (e.g., max/min). | Age field: 0, 1, 120, 121 (if max age is 120). |
| Decision Table Testing | Tests combinations of conditions. | Login: (Username valid, Password valid) → Success. |
| State Transition Testing | Tests system behavior across states (e.g., order processing: placed → shipped). | Daraz order: Cart → Checkout → Confirmed. |
4. Test Automation
Automation uses scripts/tools to execute tests repeatedly with minimal human intervention.
When to Automate?
- Regression Testing: Re-run tests after code changes.
- Repetitive Tasks: E.g., logging in 100 times to test session handling.
- Performance Testing: Simulate thousands of users (e.g., load testing for NEPSE’s trading platform).
Tools for Automation
| Tool | Type | Use Case |
|---|---|---|
| Selenium | Functional Testing | Web app UI testing (e.g., Daraz checkout). |
| JUnit | Unit Testing | Java-based unit tests. |
| Postman | API Testing | Testing REST APIs (e.g., Khalti payments). |
| JMeter | Performance Testing | Load testing (e.g., NTC’s website). |
Advantages of Automation
- Speed: Faster execution than manual testing.
- Cost-Effective: Reduces long-term manual effort.
- Accuracy: Eliminates human errors in repetitive tasks.
- Reusability: Scripts can be reused across projects.
Challenges
- Initial Setup Cost: Writing and maintaining scripts.
- Tool Dependency: Requires expertise in automation tools.
- Not All Tests Can Be Automated: Exploratory testing needs human intuition.
5. Software Testing Life Cycle (STLC)
STLC is a structured approach to testing, aligned with the software development life cycle (SDLC).
flowchart TD
A["Requirements Analysis"] --> B["Test Planning"]
B --> C["Test Case Design"]
C --> D["Test Environment Setup"]
D --> E["Test Execution"]
E --> F["Defect Reporting"]
F --> G["Test Cycle Closure"]
G -->|"Re-test if needed"| CPhases of STLC
- Requirements Analysis: Review software requirements to identify testable items.
- Test Planning: Define scope, resources, and schedule.
- Test Case Design: Create test cases using techniques like equivalence partitioning.
- Test Environment Setup: Prepare hardware/software (e.g., staging servers for eSewa).
- Test Execution: Run tests and log defects.
- Defect Reporting: Document bugs using tools like JIRA or Bugzilla.
- Test Cycle Closure: Analyze test results and generate reports.
6. Defect Management
A defect (or bug) is any discrepancy between expected and actual results.
Defect Life Cycle
stateDiagram-v2
[*] --> New
New --> Assigned
Assigned --> Fixed
Fixed --> Retest
Retest --> Reopen
Reopen --> Fixed
Fixed --> Closed
Retest --> Closed
Closed --> [*]Steps in Defect Management
- Defect Logging: Record details (steps to reproduce, severity).
- Defect Triage: Prioritize (e.g., critical vs. minor).
- Fixing: Developers resolve the issue.
- Retesting: QA verifies the fix.
- Closure: Defect is marked resolved or reopened if needed.
Severity vs. Priority
| Severity | Description | Example |
|---|---|---|
| Critical | System crash or data loss. | eSewa app crashes during payment. |
| Major | Major functionality broken. | Daraz cart items disappear randomly. |
| Minor | Partial loss of functionality. | Ncell app shows incorrect balance. |
| Trivial | Cosmetic issues. | Misspelled button text. |
| Priority | Description | Example |
|---|---|---|
| High | Must be fixed immediately. | Bank app freezes during transactions. |
| Medium | Should be fixed in the next release. | WhatsApp occasional lag. |
| Low | Fix when time permits. | YouTube minor UI glitch. |
7. Real-World Applications
Example 1: eSewa’s Transaction Testing
- Problem: eSewa must ensure 100% accuracy in financial transactions.
- Testing Applied:
- Unit Testing: Validate
processPayment()function. - Integration Testing: Check interaction between payment gateway and database.
- Regression Testing: Ensure new features (e.g., QR payments) don’t break existing ones.
- Unit Testing: Validate
- Outcome: Reduces fraud and improves user trust.
Example 2: Daraz’s Order Processing
- Problem: Daraz handles millions of orders daily; delays or errors cause losses.
- Testing Applied:
- Performance Testing: Simulate 10,000 concurrent users to check server response time.
- Usability Testing: Ensure mobile app works on low-end devices.
- Security Testing: Penetration tests to prevent hacking (e.g., credit card theft).
- Outcome: Faster deliveries and fewer order cancellations.
Example 3: NTC’s Billing Software
- Problem: NTC must bill millions of customers accurately without errors.
- Testing Applied:
- Acceptance Testing: Users (e.g., telecom agents) verify billing reports.
- Regression Testing: After tax law changes, ensure calculations update correctly.
- Outcome: Reduces customer complaints and revenue leaks.
8. Common Testing Mistakes to Avoid
- Skipping Test Planning: Leads to ad-hoc testing and missed defects.
- Ignoring Edge Cases: Focus only on happy paths (e.g., not testing empty inputs).
- Over-Automating: Not all tests (e.g., exploratory testing) can be automated.
- Poor Defect Reporting: Vague bug descriptions waste developers’ time.
- Testing Too Late: Fixing defects in later stages is costly.
9. Exam Tip
How This Unit is Examined
Theory Questions (30-40%):
- Define black-box vs. white-box testing.
- Explain STLC phases with a diagram.
- Compare unit vs. integration testing.
Scenario-Based Questions (30-40%):
- Given a login system, design 3 test cases using boundary value analysis.
- Describe how you would test Daraz’s order processing for performance.
- Explain how automation reduces regression testing effort.
Diagram-Based Questions (20-30%):
- Draw the defect life cycle or STLC flowchart.
- Sketch a test case table for a given scenario (e.g., ATM withdrawal).
Key Focus Areas for Full Marks
- Memorize: Definitions (e.g., "Software testing is the process of verifying and validating...").
- Apply: Use real-world examples (e.g., eSewa, Daraz) in answers.
- Draw: STLC, defect life cycle, or test case tables in exams.
- Compare: Tables for black-box vs. white-box, unit vs. system testing.
- Calculate: Simple test case design (e.g., "Design 2 test cases for a search function").
Sample Exam Question & Answer
Question: "Explain the difference between functional and non-functional testing with examples from Nepalese software products. Design a test case for Khalti’s ‘Add Money’ feature using boundary value analysis."
Answer: Functional Testing verifies specific functions of the software (e.g., does Khalti’s "Add Money" button work?). Non-Functional Testing checks quality attributes like performance, security, and usability (e.g., does Khalti’s app load within 2 seconds?).
| Type | Example (Khalti) | Test Focus |
|---|---|---|
| Functional | "Add Money" button transfers funds correctly. | Input: Valid account + amount; Output: Success message. |
| Non-Functional | App crashes under high load. | Simulate 5,000 users; measure response time. |
Test Case for "Add Money" (Boundary Value Analysis):
| Test Case ID | Description | Input Data | Expected Result |
|---|---|---|---|
| TC001 | Minimum amount | Amount: 1 (NPR) | Success: "Added NPR 1 to wallet." |
| TC002 | Maximum allowed amount | Amount: 500,000 (NPR) | Success: "Added NPR 500,000." |
| TC003 | Amount just above limit | Amount: 500,001 (NPR) | Error: "Amount exceeds limit." |
| TC004 | Zero amount | Amount: 0 (NPR) | Error: "Amount must be greater than 0." |
In the real world
- eSewa’s transaction validation: Uses system testing to verify end-to-end flows (user login → payment → confirmation) with real-world scenarios like failed OTP retries and bank API timeouts.
- Daraz’s order processing: Employs integration testing to ensure inventory updates, payment gateways (Khalti), and notification services (SMS/email) sync correctly without race conditions.
- NTC’s billing software: Relies on user acceptance testing (UAT) where sample customers (e.g., Ncell users) validate invoice accuracy and payment gateway integrations before full deployment.
Based on the TU BITM syllabus for Software Design and Development (IT242), unit 8.
Discussion
Loading…