Concept Flow - Why testing matters
Write Code
Run Tests
Tests Pass?
No→Fix Bugs
Retest
Code Works Well
Confident Release
This flow shows how writing code is followed by testing, fixing bugs if tests fail, and finally releasing confident code.
func add(_ a: Int, _ b: Int) -> Int { return a + b } let result = add(2, 3) print(result == 5)
| Step | Action | Evaluation | Result |
|---|---|---|---|
| 1 | Call add(2, 3) | 2 + 3 | 5 |
| 2 | Compare result == 5 | 5 == 5 | true |
| 3 | Print test result | true | true printed on screen |
| 4 | Check if test passed | true | Test passes, code works |
| Variable | Start | After Step 1 | After Step 2 | Final |
|---|---|---|---|---|
| a | - | 2 | 2 | 2 |
| b | - | 3 | 3 | 3 |
| result | - | 5 | 5 | 5 |
| testResult | - | - | true | true |
Why testing matters: - Write code - Run tests to check correctness - If tests fail, fix bugs and retest - If tests pass, code works well - Testing builds confidence before release