Concept Flow - Why testing matters
Write code
Run tests
Tests pass?
No→Fix bugs
Re-run tests
Code works well
Confident release
This flow shows how writing code, running tests, fixing bugs, and passing tests lead to confident, working software.
fun add(a: Int, b: Int): Int { return a + b } fun testAdd() { assert(add(2, 3) == 5) }
| Step | Action | Evaluation | Result |
|---|---|---|---|
| 1 | Call add(2, 3) | 2 + 3 | 5 |
| 2 | Check if add(2, 3) == 5 | 5 == 5 | True |
| 3 | Test passes | assertion holds | No error |
| 4 | Code works as expected | - | - |
| Variable | Start | After Step 1 | After Step 2 | Final |
|---|---|---|---|---|
| a | - | 2 | 2 | 2 |
| b | - | 3 | 3 | 3 |
| result | - | 5 | 5 | 5 |
| testPass | false | false | true | true |
Why testing matters: - Write code and then run tests - Tests check if code works correctly - If tests fail, fix bugs and re-test - Passing tests mean code is reliable - Testing builds confidence before release