Software Engineering(Mod 4)
Software Engineering(Mod 4)
Module 4 :
1. Coding and Testing of Software: (a) Unit Testing (b) Black Box Testing
(c) White Box Testing (d) Debugging (e) Program Analysis Tools
(f) System Testing
2. Software Reliability and Quality Assurance: (a) Reliability Metric
3. Software Quality Assurance: ISO 9000 and SEI CMM and their Comparison.
-----------------------------------------------------------------------------------------------------------
1.Coding and Testing of software :
What is Coding?
• Coding (also called implementation) is the process of translating the
software design into machine-readable code using a programming
language like Java, Python, C++, etc.
• It is the actual development phase of the software life cycle.
• The goal is to create a working, efficient, and maintainable software
product.
Example:
Imagine you are developing a Calculator App:
• Design defines a module for Addition, Subtraction, etc.
• Coding phase means actually writing the function in Java:
java
Copy code
public int add(int a, int b) {
return a + b;
}
This function would then be tested and integrated into the whole calculator.
Testing in Software Engineering
What is Testing?
• Testing is the process of verifying and validating that the software works as
intended and is free of bugs.
• It ensures the quality, security, functionality, and performance of the
software.
Objectives of Testing:
• To find errors and bugs.
• To ensure the software meets the requirements.
• To ensure reliability and performance under different conditions.
• To ensure the software is secure and usable.
1. Unit Testing:
• Tests individual modules or functions.
• Done by developers.
• Example: Testing the add() function separately.
2. Integration Testing:
• Tests how different modules work together.
• Example: Testing if the addition and subtraction modules integrate
properly in the calculator.
3. System Testing:
• Tests the entire system as a whole.
• Example: Testing the complete Calculator App.
4. Acceptance Testing:
• Done to check if the system meets business requirements.
• Done by end-users or clients.
5. Regression Testing:
• Done after changes to the code, to ensure new code has not broken
existing features.
6. Performance Testing:
• Tests if the software is fast, stable, and responsive under load.
7. Security Testing:
• Checks the software for vulnerabilities and security risks.
Phases of Testing:
1. Test Planning:
o Decide what to test, how to test, and who will test.
2. Test Case Development:
o Write test cases that describe input, action, and expected output.
3. Test Execution:
o Execute the tests manually or using automated tools.
4. Defect Reporting:
o Log any bugs or issues found during testing.
5. Defect Fixing:
o Developers fix the bugs.
6. Retesting and Regression Testing:
o Test again to verify bug fixes.
7. Final Testing and Closure:
o Verify the software is ready for release.
Testing Example:
Suppose the Calculator App you coded earlier:
• You run a test case to check if add(2, 3) returns 5.
• If it does, the test passes.
• If it returns anything else, the test fails, and you must debug the code.
Coding Testing
Developers create the software. Testers (or developers) verify the software.
• Both are dependent: Good coding simplifies testing, and good testing
ensures coding is successful.
What is Unit Testing?
• Unit Testing is a software testing technique where individual units or
components of a software are tested in isolation.
• A unit is usually the smallest testable part of an application — like a
function, method, or class.
• It validates that each unit of the software performs as expected.
• Generally done by developers during the development phase (sometimes
before, in Test-Driven Development (TDD)).
@Test
public void testAdd() {
Calculator calc = new Calculator();
int result = calc.add(2, 3);
assertEquals(5, result); // Checking if 2 + 3 = 5
}
}
Language Frameworks
C# NUnit, MSTest
PHP PHPUnit
Example Scenario:
Suppose you are building a Banking Application:
• You write a deposit() method.
• You create unit tests to check:
o Depositing a positive amount increases the balance.
o Depositing a zero or negative amount throws an error.
• These tests ensure that your deposit logic is always working.
Summary Table
Performed by Developers
Technique Description
Equivalence Dividing input data into valid and invalid partitions and
Partitioning testing one from each group.
Technique Description
State Transition
Testing the system’s behavior for different states.
Testing
Testers don't care how the input is processed internally — only whether the
output is correct.
Summary
Key Takeaway:
"Black Box Testing ensures that the software works according to the user’s
expectations without worrying about how the code is written internally."
What is Debugging?
• Debugging is the process of identifying, analyzing, and removing errors
(bugs) from software code.
• It begins after testing detects a defect and ends when the issue is
completely resolved.
• Debugging ensures that the software functions as intended without
crashing or producing wrong results.
• It is an integral part of software development and maintenance.
Objectives of Debugging:
• Locate the exact cause of a problem in the code.
• Understand why and how the error occurred.
• Fix the problem without introducing new bugs.
• Ensure that the fix works correctly across all scenarios.
Steps in Debugging:
1. Identify the Problem
o From test failure or bug report.
2. Reproduce the Error
o Run the program under the same conditions to confirm the issue.
3. Isolate the Source
o Use logs, print statements, or debuggers to narrow down the faulty
part.
4. Analyze the Root Cause
o Understand why the bug happened (logic error, typo, memory leak,
etc.).
5. Fix the Code
o Modify the code to correct the error.
6. Re-test
o Run the code again to ensure the bug is resolved and no new bugs
are introduced.
Debugging Techniques:
• Print Debugging: Using print() or console.log() to trace program flow and
variables.
• Using Debuggers: Built-in tools (like those in IDEs – VS Code, Eclipse,
PyCharm) that allow breakpoints and step-through execution.
• Rubber Duck Debugging: Explaining your code to someone (or even a
rubber duck!) to identify issues.
• Logging: Use of log files to track execution and errors.
• Backtracking: Going back from the point of failure to find the bug.