0% found this document useful (0 votes)
10 views

Unit and Integration Testing2

Uploaded by

shubam6304
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Unit and Integration Testing2

Uploaded by

shubam6304
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Practical no-6

Aim: To perform unit testing and integration testing.


Unit testing:
Unit testing is a fundamental practice in software engineering that involves testing individual
components or functions of a software application in isolation to ensure they work as
intended.
PURPOSE OF TESTING:
Validation: To verify that each unit of the software performs as expected.
Early Detection: To identify bugs and issues early in the development cycle, reducing the cost
of fixing them later.
Refactoring Support: To provide a safety net that allows developers to refactor code with
confidence, knowing that existing functionality is covered by tests.
Documentation: To serve as a form of documentation for how the code is intended to be used.
STEPS FOR UNIT TESTING:
1.Identify the Unit to Test:
Determine the specific function, method, or class that you want to test.
It’s essential to focus on small, isolated pieces of code.
2. Define Test Cases:
Normal Cases: Standard input values that should yield expected results.
Edge Cases: Extreme or boundary input values to test limits.
Error Cases: Invalid inputs to ensure the unit handles errors appropriately.
3. Set Up the Testing Environment:
Prepare the necessary testing framework and ensure all dependencies are properly
configured.
4.Write Test Code:
Initialize any required objects.
Call the method or function being tested.
Assert the expected outcome using assertions.
5. Run the Tests:
Execute the test suite using the testing framework.
This will run all the defined tests.

22
6.Analyze Results:
Review the output of the tests to identify any failures or errors. A failing test indicates a
problem in the unit under test.
7.Debug and Fix Issues:
If tests fail, investigate the underlying code to determine the cause. Fix any identified issues
and rerun the tests.
8. Refactor Code (if needed):
After fixing issues, consider refactoring the code for improvements while ensuring that the
existing tests still pass.
9.Maintain Tests:
Update tests as necessary when the code changes.
Ensure new functionality is also covered by adding relevant test cases.
10.Integrate into CI/CD Pipeline:
Incorporate unit tests into the continuous integration/continuous deployment (CI/CD) process
so that tests are run automatically whenever code changes are made.

INTEGRATION TESTING:
Integration testing is a phase in software testing where individual components or modules are
combined and tested as a group. The main goal is to identify issues that arise when different
parts of the system interact with each other.
Purpose of integration testing:
1.Detect Interface Issues:
To find problems related to the interactions between integrated components.
2.Verify Functional Flow:
To ensure that the integrated modules work together as intended and fulfil the overall
functionality of the application.
3.Early Identification of Issues:
To catch errors that might not be apparent when testing components in isolation.
STEPS FOR INTEGRATION TESTING:
1.Define Integration Test Strategy:
Determine the scope and objectives of integration testing.
Choose between top-down, bottom-up, sandwich, or big bang approaches.

23
2.Identify Integration Points:
List all the modules or components that need to be integrated.
Identify interfaces and data flow between components.
3.Develop Test Cases:
Create test cases based on integration points and expected interactions.
Include positive and negative test scenarios.
4.Set Up the Test Environment:
Prepare the environment where integration tests will be executed.
Ensure that all necessary components, databases, and services are available
5.Execute Integration Tests:
Run the test cases and observe the interactions between integrated components.
Use automated testing tools if applicable.
6.Log and Track Defects:
Record any discrepancies, failures, or unexpected behavior.
Assign severity levels to defects for prioritization.
7.Fix Defects:
Collaborate with developers to address identified issues.
Retest the components after fixes are applied.
8.Perform Regression Testing:
Ensure that fixes do not introduce new issues in previously tested areas.
Validate that the overall system functions as expected.
9.Review and Report Results:
Summarize the outcomes of integration testing.
Prepare reports detailing successes, failures, and recommendations.
10.Conduct Final Evaluation:
Assess the overall integration process and its effectiveness.
Gather feedback from team members for continuous improvement.

24

You might also like