UNIT-10 DEBUGGING AND TESTING
1
What is Debugging?
▪ Debugging is the process of identifying and resolving errors or
bugs in your code.
▪ It is used to ensure the quality of code.
▪ When there’s a problem with software, programmers analyze the
code to figure out why things aren’t working correctly.
▪ Despite being time-consuming, effective debugging is essential for
reliable and competitive code/software products.
Examples of error during debugging
▪Syntax error
▪Logical error
▪Runtime error
▪Stack overflow
▪Index Out of Bound Errors
▪Infinite loops
▪Concurrency Issues
▪I/O errors
▪Environment Dependencies
▪Integration Errors
▪Reference error
▪Type error
Advantages of Debugging
1. Improved system quality: By identifying and resolving bugs, a
system can be made more reliable and efficient, resulting in
improved overall quality.
2. Reduced system downtime: A system can be more stable and less
likely to experience downtime, which can result in improved
availability for users.
3. Increased user satisfaction: A system become more user-friendly
and better able to meet the needs of users.
4. Reduced development costs: It can save time and resources that
would otherwise be spent on fixing bugs later in the development
process or after the system has been deployed.
Advantages of Debugging
5. Increased security: A system can be made more secure, reducing
the risk of security breaches.
6. Facilitates change: With debugging it becomes easy to identify
and fix bugs that would have been caused by the changes.
7. Better understanding of the system:
8. Facilitates testing: Debugging makes easier to test the software
and ensure that it meets the requirements and specifications.
Disadvantages of Debugging
1. Time-consuming
2. Requires specialized skills
3. Can be difficult to reproduce, diagnose and Fix
4. Limited insight
5. Can be expensive
Process of Debugging
▪ The six steps of debugging
are:
[Link] the conditions
[Link] the bug
[Link] the root cause
[Link] the bug
[Link] to validate the fix
[Link] the process
▪ Four Steps of Debugging
are:
[Link] the system
[Link] the system
[Link] the mistake
[Link] the mistake.
Debugging Techniques
▪ Brute Force: Study the system for a longer duration to understand
the system.
▪ Backtracking: Backward analysis of the problem which involves
tracing the program backward from the location of the failure
message to identify the region of faulty code.
▪ Break points: Forward analysis of the program involves tracing
the program forwards using breakpoints or print statements at
different points in the program and studying the results.
▪ Cause elimination: it introduces the concept of binary
partitioning. Use a divide-and-conquer approach to explore the
code and quickly locate the bug.
▪ Automated Debugging: The use of automated tools and
techniques to assist in the debugging process.
Debugging Techniques
▪ Static analysis: Analyzing the code without executing it to identify
potential bugs or errors. This approach involves analyzing code
syntax, data flow, and control flow.
▪ Dynamic analysis: Executing the code and analyzing its behavior
at runtime to identify errors or bugs. This approach involves
techniques like runtime debugging and profiling.
▪ Collaborative debugging: Involves multiple developers working
together to debug a system. This approach is helpful in situations
where multiple modules or components are involved, and the
root cause of the error is not clear.
▪ Logging and Tracing: Using logging and tracing tools to identify
the sequence of events leading up to the error. This approach
involves collecting and analyzing logs and traces generated by the
system during its execution.
Debugging Tools
▪ The best debugging tools often depend on the specific
requirements of the project.
▪ Some common interactive debuggers include:
• GDB (GNU Debugger)
• LLDB (Low-Level Debugger)
• WinDbg (Windows Debugger)
• Visual Studio Debugger.
• IntelliJ IDEA Debugger.
• PyCharm Debugger.
• Android Studio
• ReSharper,
• Chrome DevTools
• X code.
Testing
▪ Software testing is an important process in the software
development lifecycle .
▪ It involves verifying and validating that a software application is
free of bugs, meets the technical requirements set by
its design and development , and satisfies user requirements
efficiently and effectively.
▪ It mainly aims at measuring the specification, functionality, and
performance of a software program or application.
Testing
▪ Software testing can be divided into two steps:
1. Verification: It refers to the set of tasks that ensure that the
software correctly implements a specific function. It means “Are
we building the product right?”.
2. Validation: It refers to a different set of tasks that ensure that the
software that has been built is traceable to customer
requirements. It means “Are we building the right product?”.
Test Cases
▪ Test case is a defined format for software testing required to
check if a particular application/software is working or not.
▪ A test case consists of a certain set of conditions that need to be
checked to test an application or software.
▪ A test case consists of various parameters such as ID, condition,
steps, input, expected result, result, status, and remarks, Tester
name, Test scenario, description, priority, prerequisites, etc.
▪ Test cases define how the testing would be carried out.
Test Case Template
How to write Test Cases?
▪ There are certain practices that one could follow while writing the
test cases:
▪ Simple and clear: ▪ Repetitive Results:
▪ Maintaining ▪ Different Techniques:
▪ Zero Assumptions: ▪ Create test cases with the end
▪ Traceability: user’s perspective:
▪ Different input data: ▪ Use unique Test Case ID:
▪ Strong module name: ▪ Add proper preconditions and
postconditions:
▪ Minimal Description:
▪ Test cases should be reusable:
▪ Maximum conditions:
▪ Specify the exact expected
▪ Meeting requirements:
outcome:
Types of Testing
Unit Testing
▪ Unit Testing is a software testing technique in which individual
units or components of a software application are tested in
isolation.
▪ These units are the smallest pieces of code, typically functions or
methods, ensuring they perform as expected.
▪ Unit testing helps in identifying bugs early in the development
cycle, enhancing code quality, and reducing the cost of fixing
issues later.
▪ It is an essential part of Test-Driven Development (TDD),
promoting reliable code.
Unit Testing
▪ A unit test is a small piece of code that checks if a specific function
or method in is an application works correctly.
▪ It will work as the function inputs and verifying the outputs.
▪ These tests check that the code work as expected based on the
logic the developer intended.
▪ Unit tests should run one by one, it means that they do not
depend on other system parts like databases or networks.
Instead, data stubs can be used to simulate these dependencies.
▪ Writing unit tests is easiest for simple, self-contained code blocks.
Unit Testing Strategies
▪ To create effective unit tests, follow these basic techniques to
ensure all scenarios are covered:
▪ Logic checks: Check all possible paths through the code are
tested.
▪ Boundary checks:Test how the system handles typical, edge case,
and invalid inputs. For example, if an integer between 3 and 7 is
expected, check how the system reacts to a 5 (normal), a 3 (edge
case), and a 9 (invalid input).
▪ Error handling:
▪ Object-oriented checks:
Unit Testing Tools & Techniques
1. LambdaTest
2. JUnit
3. NUnit
4. TestNG
5. PHPUnit
6. Mockito
7. Cantata
8. Karma
9. Mocha
10. TypeMock.
▪ There are Three types of Unit Testing Techniques:
1. Black Box Testing 2. White Box Testing 3. Gray Box Testing
Difference between Debugging & Testing
Testing Debugging
Testing is a process to find bugs and errors. Debugging is a process of correcting the bugs
found during testing.
The purpose of testing is to identify defects The purpose of debugging is to fix those
or errors in the software system. defects or errors.
It is the process to identify the failure of It is the process to give absolution to code
implemented code. failure.
Testing is done before debugging. Debugging is done after testing.
Testing involves executing the software Debugging involves analyzing the symptoms
system with test cases. of a problem and identifying the root cause of
the problem.
Testing can involve using automated or Debugging typically involves using tools and
manual testing tools. techniques such as logging, tracing, and code
inspection.
Testing is done by the tester. Debugging is done by either programmer or
the developer.
There is no need of design knowledge in Debugging can’t be done without proper
Thank You…