Software Testing: Views and Object-Oriented Strategies
Internal and External Views of Testing
Software testing can be approached from two perspectives:
1. Internal View: Focuses on the internal logic or structure (White Box Testing)
2. External View: Focuses on the functionality and behavior as seen by the user (Black Box Testing)
1. Internal View of Testing (White Box Testing)
Definition:
Testing approach where tester knows internal structure, code logic, and design.
Also known as white box testing, glass box testing, structural testing.
Focus:
- Control flow
- Logic paths
- Conditions and branches
- Loops and data structures
Techniques:
- Statement coverage
- Branch coverage
- Condition coverage
- Basis path testing
- Control structure testing
Who Performs:
Developers or testers with programming knowledge.
Example:
Testing nested if conditions for all true/false paths.
Advantages:
- Efficient for optimizing logic
- Detects hidden bugs
- Enables full logic coverage
Disadvantages:
- Requires code understanding
- Misses missing functionalities
2. External View of Testing (Black Box Testing)
Definition:
Tester does not know internal code. Focus on functionality.
Also called black box, behavioral, or functional testing.
Focus:
- Inputs/outputs
- Functional requirements
- System behavior
- UI
Techniques:
- Equivalence partitioning
- Boundary value analysis
- Decision tables
- State transition testing
Who Performs:
Testers, QA, end users
Example:
Testing login functionality without knowing code.
Advantages:
- No need for code
- Validates user cases
- Effective for large systems
Disadvantages:
- Misses internal logic errors
Comparison:
Feature White Box Black Box
Code Knowledge Required Not required
Focus Logic Functionality
Alias Structural Functional
Tester Developer QA/Tester
Design Basis Code logic Requirements
Conclusion:
Both approaches are essential for complete test coverage.
Test Strategies for Object-Oriented Software
Introduction:
OOS uses classes, objects, encapsulation, inheritance, polymorphism-thus needs specific testing strategies.
Objectives:
- Test object state and interactions
- Verify inheritance and polymorphism
- Validate encapsulated logic
Challenges:
- Encapsulation hides data
- Inheritance complicates coverage
- Polymorphism causes dynamic behavior
- State and object interaction is complex
Phases of OO Testing:
1. Unit Testing of Class:
- Test methods, constructors, attributes
2. Integration Testing:
- Thread-based: test system functionality
- Use-case-based: test user scenarios
3. Validation Testing:
- Ensure requirements are met
4. System Testing:
- Performance, GUI, object persistence
Techniques:
- State-Based Testing
- Class Testing
- Cluster Testing
- Scenario-Based Testing
- Mutation Testing
Example:
ATM System - classes: Account, Transaction, Card, ATMController.
Unit test each class; then test interaction during withdrawal.
Best Practices:
- Use UML/use-cases for test design
- Use tools like JUnit
- Test inheritance chains
- Use mock objects
Conclusion:
OO testing strategy ensures quality by validating both internal class behavior and inter-object collaboration.