Chapter 1: Introduction to Software Testing
1.1 What is Software Testing?
- Definition: The process of evaluating a system to check if it satisfies specified requirements. It identifies gaps, errors, or missing requirements contrary to actual requirements.
- ANSI/IEEE 1059 Standard: A process of analyzing a software item to detect differences between existing and required conditions (defects/bugs) and evaluating its features.
- Why is it necessary? Humans make mistakes. Software bugs can cause expensive, dangerous, or even fatal consequences. Testing ensures correctness across attributes like Reliability, Scalability, Portability, Reusability, and Usability.
1.2 Basic Terminology
- Fault: A static defect or flaw in the software code or design (e.g., missing validation, incorrect logic). Faults lead to errors.
- Error: An incorrect internal state that manifests due to a fault (e.g., a variable being assigned the wrong value). Errors, when triggered, manifest as failures.
- Failure: The observable inability of a software system to perform its intended function according to specifications (e.g., software crashes when a button is clicked).
- Bug/Defect: An error/issue identified during testing that needs to be fixed.
- Severity vs. Priority: Severity is the degree of impact a defect has on functionality. Priority is the level of importance assigned to fixing it.
1.3 Verification vs. Validation
These two terms are often confused but represent distinct processes:
- Verification (Static): Answers "Are you building it right?" It happens first, is done by developers, and involves static, objective checks like reviewing code and documentation to ensure the software meets defined functionality.
- Validation (Dynamic): Answers "Are you building the right thing?" It happens after verification, is done by testers, and involves dynamic, subjective execution of the software to ensure it behaves as intended for the user.
1.4 The Testing Process (When, Who, and How Much)
- Who Tests? Software Testers, Developers (Unit Testing), Project Leads/Managers, and End Users.
- When to Start: As early as the Requirements Gathering phase. Early testing reduces the cost and time of fixing bugs later.
- When to Stop: Testing is theoretically never-ending. It stops based on: testing deadlines, completion of test cases/coverage, the bug rate falling below a certain level, or management decisions.
- How Much to Test: Since exhaustive testing is impossible, teams rely on Risk Analysis (identifying high-risk functionalities) and Prioritization to focus efforts where they matter most.
1.5 Testing Techniques
- Black-Box Testing: Testers design test cases based on functionality and inputs/outputs without knowing the internal code. Techniques include:
- Equivalence Partitioning: Dividing inputs into valid/invalid groups.
- Boundary Value Analysis: Testing the extreme edges of input ranges.
- Decision Table Testing: Mapping complex business rules.
- White-Box Testing: Testers have access to the source code. Tests are designed based on internal structure. Techniques include:
- Statement Coverage: Ensuring every line of code executes at least once.
- Branch Coverage: Executing every decision point (if/else).
- Path Coverage: Executing all possible independent paths.
1.6 The Software Testing Life Cycle (STLC)
The STLC is a systematic procedure to ensure quality. Each phase has specific Entry Criteria (prerequisites) and Exit Criteria (deliverables required to close the phase).
- Requirement Analysis: The QA team analyzes the requirement document to plan testing. (Exit: Traceability Matrix, automation feasibility report).
- Test Planning: Defining the test strategy, roles, approach, automation tools, and cost estimations.
- Test Case Development/Design: Creating test steps with proper inputs, execution conditions, and expected outputs.
- Test Environment Setup: Configuring and deploying the hardware, software, and network conditions required to run the tests.
- Test Execution: Running test scripts, comparing expected vs. actual results, and logging defects.
- Test Closure: Preparing the final test result report summarizing objectives met, coverage, budget, and identified issues.
1.7 Seven Principles of Software Testing
To test optimally, strategies are built upon these 7 proven principles:
- Testing shows the presence of defects: Testing can prove bugs exist, but it cannot prove that the software is 100% bug-free.
- Exhaustive testing is not possible: Testing every single valid and invalid input combination is too time-consuming and costly.
- Early testing: Testing should start in the requirement phase; fixing bugs early is significantly cheaper.
- Defect clustering: Bugs follow the Pareto Principle (80% of problems are found in 20% of the modules).
- Pesticide paradox: Running the exact same tests repetitively will eventually fail to catch new bugs. Test cases must be regularly reviewed and updated.
- Testing is context-dependent: An e-commerce site is tested differently than a banking app. The approach depends on the software's purpose.
- Absence of errors fallacy: Having a 99% bug-free application is useless if it was built using the wrong specifications and doesn't meet the client's actual needs.
1.8 Measurement of Testing
Testing effectiveness is tracked using key metrics:
- Defect Density: Number of bugs per line of code or functional unit.
- Test Coverage: Percentage of code/functionality covered by tests.
- Time to Resolution: Average time taken to fix logged bugs.
- Traceability Matrix: Associates test cases with specific requirements to ensure full coverage.