Unit 5 - Notes - KCS076
Unit 5 - Notes - KCS076
Class testing is a method of testing individual classes in object-oriented programming to ensure they
function correctly and meet the design requirements. It focuses on verifying the methods, attributes,
and interactions within the class.
2. Check Integration: Validate how the class interacts with other classes or components.
4. Validate Encapsulation: Test the accessibility of public, protected, and private members.
o Choose a testing framework (e.g., JUnit for Java, PyTest for Python).
4. Execute Tests:
5. Evaluate Results:
1. Constructor Testing:
2. Method Testing:
o Test each method for its logic, parameters, and return values.
3. Attribute Testing:
4. Exception Testing:
5. Interaction Testing:
o Mock dependencies and validate interactions between the class and external
components.
o Use mock objects for dependencies to isolate the class being tested.
5. Automate Testing:
python
Copy code
import unittest
class Calculator:
return a + b
return a - b
class TestCalculator(unittest.TestCase):
def setUp(self):
self.calculator = Calculator()
def test_add(self):
self.assertEqual(self.calculator.add(2, 3), 5)
self.assertEqual(self.calculator.add(-1, 1), 0)
def test_subtract(self):
self.assertEqual(self.calculator.subtract(5, 3), 2)
if __name__ == "__main__":
unittest.main()
Object-Oriented Integration (OOI) refers to the process of testing the interaction and communication
between different components in an object-oriented system. These components include classes,
objects, methods, and modules. Unlike unit testing, which tests individual classes, OOI focuses on
how these classes and objects work together to achieve the desired functionality.
1. Verify Collaboration: Ensure that objects interact and exchange data correctly.
2. Check Relationships: Validate associations (inheritance, aggregation, and composition)
among classes.
3. Identify Defects: Find issues like incorrect method calls, data flow errors, or inconsistent
behavior.
4. Assess System Behavior: Test how integrated components meet functional requirements.
5. Ensure Robustness: Handle edge cases and identify unhandled exceptions during object
interactions.
Characteristics of OOI:
o Tests how objects exchange messages and call methods on each other.
3. Dynamic Binding:
4. State-Based Testing:
1. Top-Down Integration:
o Start testing high-level classes first, then gradually include lower-level classes.
2. Bottom-Up Integration:
o Suitable for small systems but risky for large ones due to difficulty in debugging.
o Useful for complex systems where both high-level and low-level testing is essential.
5. Cluster Testing:
1. Identify Components:
o Create test cases for possible interactions between objects (e.g., method calls, data
exchange).
3. Set Up Dependencies:
5. Execute Tests:
6. Evaluate Results:
1. Complex Relationships:
2. State Dependency:
o Objects often rely on specific states, which makes testing all scenarios challenging.
3. Tight Coupling:
4. Concurrency Issues:
2. Automate Testing:
o Use tools like JUnit (Java), Mockito (for mocking), or PyTest (Python) to streamline
testing.
o Prioritize integration points most likely to fail, such as complex or frequently used
interactions.
o Validate base and derived class interactions, especially overridden and virtual
methods.
python
Copy code
# Classes to test
class Account:
self.balance = balance
self.balance -= amount
return True
return False
class ATM:
# Integration Test
import unittest
class TestATMIntegration(unittest.TestCase):
def test_transaction_success(self):
account = Account(100)
atm = ATM(account)
result = atm.process_transaction(50)
self.assertEqual(result, "Success")
self.assertEqual(account.balance, 50)
def test_transaction_failure(self):
account = Account(100)
atm = ATM(account)
result = atm.process_transaction(150)
self.assertEqual(account.balance, 100)
def test_mocked_account(self):
mock_account = MagicMock()
mock_account.withdraw.return_value = False
atm = ATM(mock_account)
result = atm.process_transaction(50)
if __name__ == "__main__":
unittest.main()
Web Testing:
Web testing is the process of testing web applications or websites to ensure they function correctly,
are secure, and provide a good user experience across different environments. It involves evaluating
various aspects of a web application, including functionality, performance, security, usability, and
compatibility.
1. Functionality: Ensure all features and workflows of the web application operate as intended.
2. Compatibility: Verify the application works across multiple browsers, devices, and operating
systems.
3. Performance: Test the application’s behavior under different loads and stress conditions.
5. Usability: Evaluate the ease of use, navigation, and overall user experience.
6. Localization: Check the web application for proper formatting, translations, and cultural
relevance in different regions.
1. Functional Testing
● Focuses on:
o Cookies: Check if cookies are being stored correctly and can be deleted.
o Database: Validate data integrity during Create, Read, Update, Delete (CRUD)
operations.
2. Usability Testing
● Includes:
3. Interface Testing
● Checks:
4. Compatibility Testing
5. Performance Testing
● Tests the application's stability, scalability, and speed under different conditions.
● Includes:
o Stress Testing: Push the application beyond its capacity to identify breaking points.
6. Security Testing
● Focuses on:
7. Responsive Testing
● Ensures the application adapts and displays properly on devices with different screen sizes,
orientations, and resolutions.
8. Localization and Globalization Testing
● Localization Testing: Ensures the application is customized for specific regions, including
language, currency, and date/time formats.
● Globalization Testing: Verifies the application's ability to handle multiple languages and
cultural settings without errors.
1. Understand Requirements:
5. Execute Tests:
8. Final Validation:
o Perform a final round of testing to ensure the application meets quality standards.
4. Performance Bottlenecks: Identifying and fixing slow responses under heavy traffic.
5. Data Security: Ensuring compliance with data protection regulations like GDPR.
o Check how the application handles errors, including 404 and 500 statuses.
Pass
Pass/Fail
UI Testing is the process of verifying that the graphical user interface of an application meets the
required functionality, usability, and accessibility standards. The focus is on ensuring that the
interface is user-friendly, visually appealing, and behaves as expected across different platforms and
environments.
1. Functionality: Ensure that all UI components (buttons, text fields, menus, etc.) perform their
intended actions.
2. Usability: Verify that the interface is intuitive and easy to use for the target audience.
3. Accessibility: Ensure compliance with accessibility standards (e.g., WCAG) for users with
disabilities.
4. Compatibility: Test the UI across various browsers, devices, screen resolutions, and operating
systems.
5. Consistency: Ensure uniform design and behavior across all parts of the application.
6. Error Handling: Validate how the UI handles errors or invalid inputs gracefully.
Aspects of UI Testing
2. Functional Testing:
3. Responsiveness Testing:
4. Accessibility Testing:
o Ensure compliance with standards like WCAG, Section 508, and ARIA.
5. Performance Testing:
6. Cross-Browser/Device Testing:
o Ensure UI consistency across browsers (Chrome, Firefox, Safari, etc.) and devices
(mobile, tablet, desktop).
o Validate that appropriate and clear error messages are displayed for invalid inputs.
Steps in UI Testing
1. Understand Requirements:
o Include test cases for edge scenarios, such as invalid inputs or missing data.
4. Execute Tests:
5. Log Defects:
o Ensure that defects are resolved and do not introduce new issues.
7. Final Validation:
Types of UI Testing
1. Manual UI Testing:
2. Automated UI Testing:
3. Exploratory Testing:
4. A/B Testing:
1. Automation Tools:
UI Testing Checklist
● Verify alignment, font styles, sizes, and colors match the design.
● Validate that UI elements (e.g., buttons, menus) are correctly sized and spaced.
5. Cross-Browser/Device Checklist
1. Frequent UI Changes:
2. Dynamic Elements:
3. Cross-Browser Compatibility:
4. Localization Issues:
4. Involve Designers:
o Start testing during development and perform regression tests after each update.
Pass/Fail Pass
Class testing is a method of testing individual classes in object-oriented programming to ensure they
function correctly and meet the design requirements. It focuses on verifying the methods, attributes,
and interactions within the class.
2. Check Integration: Validate how the class interacts with other classes or components.
4. Validate Encapsulation: Test the accessibility of public, protected, and private members.
o Choose a testing framework (e.g., JUnit for Java, PyTest for Python).
4. Execute Tests:
5. Evaluate Results:
o Compare actual output with expected results.
1. Constructor Testing:
2. Method Testing:
o Test each method for its logic, parameters, and return values.
3. Attribute Testing:
4. Exception Testing:
5. Interaction Testing:
o Mock dependencies and validate interactions between the class and external
components.
o Use mock objects for dependencies to isolate the class being tested.
python
Copy code
import unittest
class Calculator:
return a + b
return a - b
class TestCalculator(unittest.TestCase):
def setUp(self):
self.calculator = Calculator()
def test_add(self):
self.assertEqual(self.calculator.add(2, 3), 5)
self.assertEqual(self.calculator.add(-1, 1), 0)
def test_subtract(self):
self.assertEqual(self.calculator.subtract(5, 3), 2)
if __name__ == "__main__":
unittest.main()
1. Verify Collaboration: Ensure that objects interact and exchange data correctly.
3. Identify Defects: Find issues like incorrect method calls, data flow errors, or inconsistent
behavior.
4. Assess System Behavior: Test how integrated components meet functional requirements.
5. Ensure Robustness: Handle edge cases and identify unhandled exceptions during object
interactions.
Characteristics of OOI:
o Tests how objects exchange messages and call methods on each other.
3. Dynamic Binding:
4. State-Based Testing:
1. Top-Down Integration:
o Start testing high-level classes first, then gradually include lower-level classes.
2. Bottom-Up Integration:
o Suitable for small systems but risky for large ones due to difficulty in debugging.
4. Hybrid (Sandwich) Integration:
o Useful for complex systems where both high-level and low-level testing is essential.
5. Cluster Testing:
1. Identify Components:
o Create test cases for possible interactions between objects (e.g., method calls, data
exchange).
3. Set Up Dependencies:
5. Execute Tests:
6. Evaluate Results:
1. Complex Relationships:
2. State Dependency:
o Objects often rely on specific states, which makes testing all scenarios challenging.
3. Tight Coupling:
4. Concurrency Issues:
2. Automate Testing:
o Use tools like JUnit (Java), Mockito (for mocking), or PyTest (Python) to streamline
testing.
o Prioritize integration points most likely to fail, such as complex or frequently used
interactions.
o Validate base and derived class interactions, especially overridden and virtual
methods.
1. Mocking Frameworks:
Web Testing:
Web testing is the process of testing web applications or websites to ensure they function correctly,
are secure, and provide a good user experience across different environments. It involves evaluating
various aspects of a web application, including functionality, performance, security, usability, and
compatibility.
1. Functionality: Ensure all features and workflows of the web application operate as intended.
2. Compatibility: Verify the application works across multiple browsers, devices, and operating
systems.
3. Performance: Test the application’s behavior under different loads and stress conditions.
5. Usability: Evaluate the ease of use, navigation, and overall user experience.
6. Localization: Check the web application for proper formatting, translations, and cultural
relevance in different regions.
1. Functional Testing
● Focuses on:
o Cookies: Check if cookies are being stored correctly and can be deleted.
o Database: Validate data integrity during Create, Read, Update, Delete (CRUD)
operations.
2. Usability Testing
● Includes:
3. Interface Testing
● Checks:
4. Compatibility Testing
5. Performance Testing
● Tests the application's stability, scalability, and speed under different conditions.
● Includes:
o Stress Testing: Push the application beyond its capacity to identify breaking points.
6. Security Testing
● Focuses on:
7. Responsive Testing
● Ensures the application adapts and displays properly on devices with different screen sizes,
orientations, and resolutions.
● Localization Testing: Ensures the application is customized for specific regions, including
language, currency, and date/time formats.
● Globalization Testing: Verifies the application's ability to handle multiple languages and
cultural settings without errors.
1. Understand Requirements:
5. Execute Tests:
8. Final Validation:
o Perform a final round of testing to ensure the application meets quality standards.
4. Performance Bottlenecks: Identifying and fixing slow responses under heavy traffic.
5. Data Security: Ensuring compliance with data protection regulations like GDPR.
o Check how the application handles errors, including 404 and 500 statuses.
UI Testing is the process of verifying that the graphical user interface of an application meets the
required functionality, usability, and accessibility standards. The focus is on ensuring that the
interface is user-friendly, visually appealing, and behaves as expected across different platforms and
environments.
1. Functionality: Ensure that all UI components (buttons, text fields, menus, etc.) perform their
intended actions.
2. Usability: Verify that the interface is intuitive and easy to use for the target audience.
3. Accessibility: Ensure compliance with accessibility standards (e.g., WCAG) for users with
disabilities.
4. Compatibility: Test the UI across various browsers, devices, screen resolutions, and operating
systems.
5. Consistency: Ensure uniform design and behavior across all parts of the application.
6. Error Handling: Validate how the UI handles errors or invalid inputs gracefully.
Aspects of UI Testing
2. Functional Testing:
3. Responsiveness Testing:
4. Accessibility Testing:
o Ensure compliance with standards like WCAG, Section 508, and ARIA.
5. Performance Testing:
o Ensure UI consistency across browsers (Chrome, Firefox, Safari, etc.) and devices
(mobile, tablet, desktop).
o Validate that appropriate and clear error messages are displayed for invalid inputs.
Steps in UI Testing
1. Understand Requirements:
o Include test cases for edge scenarios, such as invalid inputs or missing data.
4. Execute Tests:
5. Log Defects:
o Ensure that defects are resolved and do not introduce new issues.
7. Final Validation:
Types of UI Testing
1. Manual UI Testing:
2. Automated UI Testing:
o Uses tools to simulate user actions and validate UI behavior.
3. Exploratory Testing:
4. A/B Testing:
1. Automation Tools:
UI Testing Checklist
● Verify alignment, font styles, sizes, and colors match the design.
5. Cross-Browser/Device Checklist
1. Frequent UI Changes:
2. Dynamic Elements:
3. Cross-Browser Compatibility:
4. Localization Issues:
4. Involve Designers:
o Start testing during development and perform regression tests after each update.
Pass
Pass/Fail
Security Testing:
Security Testing is a type of software testing that ensures an application is secure from
vulnerabilities, threats, and risks. The goal is to identify weaknesses in the system and ensure data
integrity, confidentiality, and availability are maintained.
1. Identify Vulnerabilities:
o Ensure only authorized users can access the application and its data.
o Verify that sensitive data is not altered or tampered with during transmission or
storage.
1. Vulnerability Scanning:
3. Security Audit:
4. Ethical Hacking:
5. Risk Assessment:
o Identifies and prioritizes risks to focus remediation efforts on the most critical areas.
o Analyzes the source code to identify security vulnerabilities during the development
phase.
8. Compliance Testing:
o Verifies that security fixes applied in previous versions are still intact after updates or
changes.
1. Injection Attacks:
o Attackers inject scripts into web pages viewed by other users, leading to data theft or
unauthorized actions.
6. Security Misconfigurations:
1. Manual Testing
● Useful for identifying logical flaws that automated tools might miss.
2. Automated Testing
6. Compliance Tools:
1. Understand Requirements:
4. Execute Tests:
5. Analyze Results:
6. Fix Vulnerabilities:
7. Document Findings:
8. Implement Monitoring:
Area Tasks
Input Validation Test for injection vulnerabilities (e.g., SQL injection, XSS).
Session Management Validate secure session handling (e.g., session timeouts, secure cookies).
Data Encryption Check for encryption of sensitive data at rest and in transit.
Error Handling Ensure error messages do not reveal sensitive system information.
Area Tasks
Third-Party Components Test for vulnerabilities in libraries and frameworks used by the application.
1. Evolving Threats:
2. Limited Time:
3. Complex Environments:
4. False Positives:
5. Lack of Expertise:
o Align with frameworks like OWASP Top 10, NIST, and ISO 27001.
6. Educate Developers:
Database Testing:
Database Testing is a type of software testing that focuses on verifying the integrity, reliability, and
accuracy of databases and the data they manage. The goal is to ensure that database operations
(such as queries, updates, deletes, and transactions) function as expected and that the database is
secure, optimized, and error-free.
1. Data Integrity:
2. Data Validation:
o Verify that data complies with the required formats, ranges, and constraints.
3. Database Performance:
4. Database Security:
5. Data Transactions:
o Validate the reliability of CRUD (Create, Read, Update, Delete) operations and ACID
properties (Atomicity, Consistency, Isolation, Durability).
1. Structural Testing:
o Ensures database objects are properly defined and aligned with requirements.
2. Functional Testing:
o Validates the functionality of database operations (e.g., data insertion, updates, and
deletion).
3. Non-Functional Testing:
o Includes performance testing, stress testing, and scalability testing for the database.
1. Schema Testing
3. Validation Testing
● Check constraints such as primary keys, foreign keys, unique constraints, and default values.
● Test triggers to ensure they fire at the correct times and with the correct results.
● Verify that data has been correctly migrated or transformed during system upgrades or
changes.
● Test database backup procedures and ensure data recovery is reliable and consistent.
1. Understand Requirements:
4. Execute Tests:
6. Retest:
o After resolving issues, retest to confirm that changes have not introduced new
errors.
● Focuses on verifying database inputs and outputs without considering internal structure or
logic.
● Tests the internal structure of the database, including SQL queries, stored procedures, and
triggers.
3. Automated Testing:
● Uses tools to automate repetitive test cases, such as running queries and verifying results.
2. Automation Tools:
o Selenium with JDBC/ODBC: For automating database tests via web applications.
o QTP/UFT: For functional database testing.
Area Tasks
Schema Validation Verify table structures, column names, data types, and constraints.
Stored Procedures Validate the logic, input/output, and performance of stored procedures.
Performance Test query execution times and database response under load.
Status Pass/Fail
Status Pass/Fail
Status Pass/Fail
2. Complex Schemas:
3. Data Dependencies:
4. Limited Access:
o Testing with production data must ensure data privacy and security.
3. Focus on Performance:
o Maintain records of schema changes and ensure tests are updated accordingly.
o 1. Encapsulation Challenges
o Issue:
o Encapsulation hides the internal details of objects, making it difficult to access and
test private or protected attributes and methods.
o Impact:
o Testers may need to rely on public interfaces, which might not fully expose the
object’s behavior for comprehensive testing.
o Resolution:
o Use reflection techniques (where applicable) or create testing access points (e.g.,
getter methods) to test internal states.
o 2. Inheritance Complexity
o Issue:
o Impact:
o Requires thorough testing of the inheritance tree and all overridden and inherited
methods.
o Resolution:
o Test overridden methods independently to ensure the child class maintains expected
behavior.
o Issue:
o With polymorphism, objects can take multiple forms, and methods may exhibit
different behaviors at runtime.
o Impact:
o Increases the complexity of designing test cases since behavior depends on the
runtime object type.
o Resolution:
o Issue:
o Impact:
o Faults in one object can cascade into other interacting objects, making it hard to
isolate and diagnose issues.
o Resolution:
o Use mock objects, stubs, or dependency injection to isolate and test individual
object interactions.
o 5. State-Based Behavior
o Issue:
o Objects often maintain internal states, and their behavior can vary depending on the
state.
o Impact:
o Testing all possible state transitions and their corresponding behaviors can be
time-consuming and complex.
o Resolution:
o Use state transition diagrams to model and test all state changes and transitions
systematically.
o Issue:
o OO languages support method overloading (methods with the same name but
different signatures) and operator overloading.
o Impact:
o Resolution:
o Create separate test cases for each overloaded method/operator to ensure they
handle their specific inputs and outputs correctly.
o Issue:
o Abstract classes and interfaces cannot be instantiated directly, making direct testing
impossible.
o Impact:
o Resolution:
o Issue:
o Impact:
o Resolution:
o Apply dependency injection or use mocks and stubs to simulate dependent objects
during testing.
o 9. Reusability of Objects
o Issue:
o Impact:
o Changes in reusable objects might break functionality in other parts of the system.
o Resolution:
o Issue:
o Impact:
o Resolution:
o Issue:
o As the size of the OO system grows, the number of objects and their interactions
increase exponentially.
o Impact:
o Resolution:
o Break down testing into smaller modules and focus on testing individual components
before integration.
o Issue:
o Objects go through various lifecycles, such as creation, usage, and destruction.
o Memory leaks or improper cleanup can occur if objects are not managed correctly.
o Impact:
o Resolution:
o Issue:
o Impact:
o Resolution:
o Use stress testing and thread analysis tools to identify concurrency issues.
o Issue:
o OO testing often requires tools for mocking, state testing, and dynamic analysis, but
the available tools might not fully meet the needs.
o Impact:
o Resolution:
o Use a combination of unit testing frameworks (e.g., JUnit, NUnit) and mocking
libraries (e.g., Mockito) to improve coverage and efficiency.
o Issue:
o Impact:
o Regularly update test cases and automate regression testing to handle frequent code
changes.
o Design test cases for reusable components and use modular tests to reduce
redundancy.
o Write tests before implementing methods to ensure proper coverage from the start.
o Leverage Automation:
o Automate unit and regression testing to handle repetitive and complex scenarios
efficiently.
o Pay attention to object interactions and data flow between objects during
integration testing.
o Simulate dependencies using mocking tools to isolate and test individual object
behavior.
THE END