2.10.1 Testing
Python Programming
Testing is the process of running your code with various inputs to check if it behaves as expected. The goal is to find and fix any issues before the code is used in real-world applications.
2.10.1.1 Types of Testing
- Unit Testing: Tests individual parts of the code (like functions or classes) in isolation. Python's unittest module is commonly used for this.
- Integration Testing: Checks how different parts of the code work together.
- Functional Testing: Validates that the software behaves as expected from the user's perspective.
- Regression Testing: Ensures that new changes don't break existing functionality. Example: In this example, we use the unittest module to test the add function. This ensures that the function returns the correct results by checking various input values.
python
import unittest
def add (a , b) :
return a + b
class