Cause-Effect Graphing Testing
Definition:
Cause-Effect Graphing is a black-box testing technique that identifies input combinations
(causes) and their corresponding system behaviors (effects).
Steps:
1. Identify Causes and Effects:
o Causes: Inputs or conditions.
o Effects: Outputs or system states.
2. Build a Cause-Effect Graph:
o Represent causes and effects as nodes.
o Use logical operators (AND, OR, NOT) to define relationships.
3. Generate Test Cases:
o Derive test cases by traversing the graph to cover all combinations.
Use Case:
Suitable for systems with complex input-output relationships.
Structural Testing
Definition:
Structural Testing, also called white-box testing, verifies the internal workings of the
software.
Types:
1. Statement Coverage:
o Ensures all executable statements are executed at least once.
2. Branch Coverage:
o Ensures every decision (if/else) outcome is executed.
3. Condition Coverage:
o Tests all individual conditions in a decision.
Purpose:
Ensure all parts of the code are tested to avoid hidden bugs.
Path Testing
Definition:
A white-box testing technique that ensures all possible execution paths in the program are
tested.
Steps:
1. Draw a Control Flow Graph (CFG):
o Nodes represent statements or blocks of code.
o Edges represent control flow between nodes.
2. Identify Independent Paths:
o Each path should introduce at least one new edge not covered by other paths.
3. Generate Test Cases:
o Create input data to traverse each independent path.
Formula for Paths:
Use Cyclomatic Complexity (V): V=E−N+2PV = E - N + 2PV=E−N+2P Where:
o EEE: Edges.
o NNN: Nodes.
o PPP: Connected components (usually 1 for a single program).
Example:
For a program with loops and conditions, path testing ensures all possibilities (e.g., loop executed 0,
1, or multiple times) are tested.
Data Flow Testing
Definition:
A white-box testing technique that focuses on the flow of data through the program.
Key Aspects:
1. Definition: When a variable is assigned a value.
2. Use: When the variable is used in a computation or decision.
Steps:
1. Identify Variables:
o Locate all defined and used variables in the code.
2. Create a Data Flow Graph:
o Nodes: Program statements.
o Edges: Flow between statements.
3. Generate Test Cases:
o Test paths to ensure each variable's lifecycle (definition to use) is covered.
Faults Detected:
Undefined variables, unused variables, and incorrect assignments.
Mutation Testing
Definition:
Mutation Testing evaluates the quality of test cases by introducing small changes (mutants)
to the program and checking if the test cases detect them.
Process:
1. Create Mutants:
o Modify code slightly (e.g., changing operators, constants, or variables).
2. Run Test Cases:
o Execute existing test cases on the original and mutated programs.
3. Analyze Results:
o If a test case fails for a mutant, it "kills" the mutant.
o Surviving mutants indicate missing or weak test cases.
Types of Mutations:
1. Statement Mutation: Modify or delete a statement.
2. Operator Mutation: Replace operators (e.g., + to -).
3. Variable Mutation: Replace variables with others.
Objective:
Measure test suite effectiveness and identify weak areas.
Unit Testing
Definition:
Unit testing is a level of software testing where individual units or components of a software are
tested in isolation. The goal is to ensure that each part of the program works as expected.
Purpose:
To validate that each unit (function, method, or class) behaves as intended.
To catch bugs early during development.
Example:
Consider a simple function that adds two numbers:
python
Copy code
def add(a, b):
return a + b
Test Case:
Input (a, b) Expected Output Actual Output Pass/Fail
3, 2 5 5 Pass
-1, 2 1 1 Pass
0, 0 0 0 Pass
Tools for Unit Testing:
JUnit (Java): A framework for Java unit tests.
PyTest (Python): A framework to write test cases for Python programs.
NUnit (C#): Used for testing .NET applications.
Advantages:
Catches issues early in development.
Ensures the correctness of individual components.
Improves code quality and maintainability.
Integration Testing
Definition:
Integration testing involves testing the interaction between different units/modules to ensure they
work together as expected. It checks if the integrated components or systems work as intended
when combined.
Purpose:
To detect issues that may arise when different software modules or systems are combined.
To validate data flow and control flow between modules.
Example:
Consider two modules:
Module 1 (User Service): Responsible for handling user registration.
Module 2 (Database Service): Responsible for storing user data in the database.
Test Case:
Objective: Ensure that when a user is registered in the User Service, the data is correctly
stored in the Database Service.
Test: A user provides a username and password, and the registration module interacts with
the database to store the user's information.
Tools for Integration Testing:
JUnit (Java): Can also be used for integration tests.
Postman: Used for testing API integrations.
SoapUI: Used for web service integration testing.
Advantages:
Identifies problems that occur when different modules work together.
Validates data transfer between modules.
System Testing
Definition:
System testing is a type of testing where the entire system is tested as a whole to verify that it meets
the specified requirements. It checks if the complete system works in all environments and
conditions.
Purpose:
To ensure the system meets the business requirements and performs as expected under
different conditions.
To validate both functional and non-functional requirements.
Example:
Consider an e-commerce application. The system needs to perform the following tasks:
1. Display products.
2. Add products to the cart.
3. Process payments.
4. Generate invoices.
Test Case:
Test all features and workflows, including adding an item to the cart, checking out, and
generating an invoice.
Tools for System Testing:
Selenium: For automated testing of web applications.
QTP (QuickTest Professional): For automating GUI tests in desktop applications.
LoadRunner: For performance and load testing.
Advantages:
Verifies that the entire system meets requirements.
Helps detect any defects that might arise in a fully integrated system.
Debugging Testing
Definition:
Debugging testing involves identifying and fixing errors or bugs in the program code during the
development process. It’s an ongoing process where the developer uses debugging tools to isolate
the cause of an issue.
Purpose:
To detect and fix issues in code.
To improve software quality by resolving errors before deployment.
Example:
Code Example:
python
Copy code
def multiply(a, b):
result = a + b # Error: Should be multiplication, not addition
return result
Test Case to Debug:
Input: 3, 4
Expected Output: 12
Actual Output: 7
Debugging Step: The error is identified when checking the operation (+ should be *).
Tools for Debugging:
GDB (GNU Debugger): For debugging C and C++ programs.
PyCharm Debugger: Integrated into the PyCharm IDE for debugging Python code.
Eclipse Debugger: For Java-based programs.
Advantages:
Ensures the program works as expected by identifying and correcting bugs.
Improves software reliability and stability.
Tools and Standards in Software Testing
Testing Tools
1. JUnit:
o Used for: Unit testing in Java.
o Key Feature: Allows for easy creation of automated tests for Java classes.
2. Selenium:
o Used for: Web application testing.
o Key Feature: Supports browser automation and can perform cross-browser testing.
3. Postman:
o Used for: API testing.
o Key Feature: Allows you to send HTTP requests and inspect responses in detail.
4. QTP (QuickTest Professional):
o Used for: Functional and regression testing of applications.
o Key Feature: Allows for automated functional testing of both web and desktop
applications.
5. LoadRunner:
o Used for: Load and performance testing.
o Key Feature: Helps simulate user loads and test how well the application performs
under heavy traffic.
Testing Standards
1. IEEE 829:
o Description: Standard for software test documentation, including test plans, test
design, and test reporting.
o Use: Helps ensure a consistent approach to software testing across organizations.
2. ISO/IEC 9126:
o Description: Defines software product quality standards, including functionality,
reliability, usability, efficiency, maintainability, and portability.
o Use: Ensures that software meets a certain level of quality in terms of performance
and user experience.
3. ISTQB (International Software Testing Qualifications Board):
o Description: An international organization that offers certification for software
testers.
o Use: Provides a recognized standard for testing practices and a structured career
path for testers.
4. CMMI (Capability Maturity Model Integration):
o Description: A framework for improving the processes of software development and
testing.
o Use: Helps organizations to improve their software development processes and
create high-quality software.