Testing Formula
The Formula
When to use: Try to break it before users do. Test normal cases, edge cases, and error cases.
Quick Example
What This Formula Means
Systematically running a program with known inputs to verify that its outputs are correct. Testing involves designing test cases that cover normal inputs, boundary values, and error conditions, then comparing actual results against expected results.
Try to break it before users do. Test normal cases, edge cases, and error cases.
Formal View
Worked Examples
Example 1
easySolution
- 1 Step 1: Normal test: isEven(4) should return TRUE. This tests typical valid input.
- 2 Step 2: Boundary test: isEven(0) should return TRUE. Zero is an edge case that is technically even.
- 3 Step 3: Erroneous test: isEven('hello') should handle the invalid input gracefully (return an error or FALSE). This tests that the function does not crash on bad input.
Answer
Example 2
mediumCommon Mistakes
- Only testing the happy path (normal inputs) and neglecting edge cases and error conditions
- Writing tests that depend on each other's execution order instead of being independent
- Assuming that passing all tests means the program is bug-freeβtesting can only show the presence of bugs, not their absence
Common Mistakes Guide
If this formula feels simple in isolation but keeps breaking during real problems, review the most common errors before you practice again.
Why This Formula Matters
Quality software requires thorough, systematic testing because bugs found early cost far less to fix. Professional software teams typically write more test code than production code, and automated testing catches regressions before they reach users.
Frequently Asked Questions
What is the Testing formula?
Systematically running a program with known inputs to verify that its outputs are correct. Testing involves designing test cases that cover normal inputs, boundary values, and error conditions, then comparing actual results against expected results.
How do you use the Testing formula?
Try to break it before users do. Test normal cases, edge cases, and error cases.
Why is the Testing formula important in CS Thinking?
Quality software requires thorough, systematic testing because bugs found early cost far less to fix. Professional software teams typically write more test code than production code, and automated testing catches regressions before they reach users.
What do students get wrong about Testing?
Test edge cases: empty input, zero, maximum values, unexpected types.
What should I learn before the Testing formula?
Before studying the Testing formula, you should understand: algorithm, debugging.