Software Engineering Unit 4 - @mrsandyy_
Software Engineering Unit 4 - @mrsandyy_
in
2. Principles of Testing
2.1 The Testing Process
The testing process involves the following stages:
Requirement Analysis: Understanding the functional and non-functional requirements of the
system.
Test Planning: Defining the test strategy, selecting the testing tools, and determining the
resources needed.
Unit 4 Software Engineering mrsandy.in
Test Design: Designing test cases, scenarios, and scripts based on requirements.
Test Execution: Running the test cases on the software.
Defect Reporting: Reporting and tracking defects found during testing.
Test Closure: Concluding the testing process after achieving the desired results.
2.2 Testing Principles
The key principles of software testing include:
Testing shows the presence of defects: Testing can prove that defects exist, but it cannot
prove their absence.
Exhaustive testing is impossible: Testing every possible input and scenario is impractical,
so testing must be selective.
Early testing: The earlier testing begins in the software development lifecycle, the more
effective it is in detecting defects.
Defect clustering: A small number of modules often contain the majority of defects.
Pesticide paradox: Repeating the same set of tests will not lead to new defects being
discovered. New tests need to be added.
Testing is context-dependent: Testing approaches and strategies must be chosen based
on the type of software being developed and its requirements.
3. Testability
Testability refers to the ease with which a software system can be tested. It is influenced by
factors such as the availability of clear requirements, the modularity of the code, and the use of
well-defined interfaces. A highly testable system is easier to validate and ensures that defects can
be identified quickly.
3.1 Factors Affecting Testability
Modularity: Well-structured, modular code is easier to test.
Simplicity: The simpler the design, the easier it is to test.
Observability: The system must provide sufficient feedback (logs, outputs) during testing.
Controllability: Testers must be able to control the system's behavior during testing, such as
setting conditions or inputs.
Isolation: Components should be loosely coupled to enable independent testing.
Unit 4 Software Engineering mrsandy.in
4. Test Cases
4.1 Test Cases Definition
A test case is a set of conditions or variables under which a tester evaluates the software to check
if it behaves as expected. Test cases are essential for verifying that a system functions correctly
and meets its requirements.
Components of a Test Case:
Test Case ID: Unique identifier for the test case.
Test Description: A brief description of what the test case does.
Preconditions: Any setup or conditions that must be satisfied before executing the test.
Test Steps: A sequence of actions to perform the test.
Expected Result: The anticipated outcome based on the test conditions.
Actual Result: The actual outcome after running the test.
Postconditions: The expected state of the system after the test has completed.
Status: Whether the test passed or failed.
Example of a Test Case:
Test Case ID: TC001
Test Description: Verify the login functionality
Preconditions: User is on the login page
Test Steps:
1. Enter a valid username.
2. Enter the correct password.
3. Click the "Login" button.
Expected Result: The user should be redirected to the dashboard page.
Actual Result: The user was redirected to the dashboard page.
Status: Pass
5. Testing Strategies
5.1 White Box Testing
White Box Testing, also known as Structural Testing or Glass Box Testing, involves testing
the internal workings of a system. Testers need to have knowledge of the code structure, logic,
and algorithms.
Unit 4 Software Engineering mrsandy.in
Features:
Code Coverage: Ensures that all branches, paths, and conditions are tested.
Focuses on Implementation: Focuses on how the system operates internally rather than its
external behavior.
Types of White Box Testing:
Statement Coverage: Ensures that every statement in the code is executed at least once.
Branch Coverage: Ensures that every branch (decision point) in the code is tested.
Path Coverage: Ensures that every possible path through the code is executed.
Advantages:
Allows detection of hidden errors in the code.
Helps in optimizing code performance and logic.
Disadvantages:
Requires knowledge of the code, making it more time-consuming.
May miss issues related to external interfaces or user inputs.
Advantages:
No knowledge of the internal code is required.
Can be done by non-developers (e.g., QA engineers or end users).
Disadvantages:
Cannot uncover code-level issues or logic flaws.
May not be exhaustive as it can miss certain edge cases.
7. Levels of Testing
7.1 Unit Testing
Unit Testing involves testing individual units or components of the software in isolation, usually by
the developer. It focuses on validating the functionality of specific functions, methods, or classes.
Example:
Unit 4 Software Engineering mrsandy.in
# Unit Test
def test_add():
assert add(2, 3) == 5