Why testing ensures software quality in Software Engineering - Performance Analysis
Testing helps find problems in software before users see them.
We want to know how the time spent testing grows as the software gets bigger.
Analyze the time complexity of the following testing process.
for each feature in software:
for each test_case in feature.tests:
run(test_case)
check_results()
This code runs all test cases for every feature in the software to check correctness.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Running each test case and checking results.
- How many times: For every feature, all its test cases are run once.
As the number of features or test cases grows, the total tests run grow too.
| Input Size (features x tests) | Approx. Operations |
|---|---|
| 10 features x 5 tests | 50 test runs |
| 100 features x 5 tests | 500 test runs |
| 1000 features x 5 tests | 5000 test runs |
Pattern observation: The total test runs increase directly with the number of features and tests.
Time Complexity: O(n * m)
This means the testing time grows proportionally to the number of features times the number of tests per feature.
[X] Wrong: "Testing time stays the same no matter how big the software is."
[OK] Correct: More features and tests mean more checks, so testing takes longer as software grows.
Understanding how testing time grows helps you plan and explain software quality efforts clearly.
"What if we automated some tests to run in parallel? How would the time complexity change?"