Concept Flow - Minitest basics (assert style)
Write test method
Call assert method
Evaluate condition
Pass
Report result
Next test or end
Tests run by calling assert methods that check conditions; if true, test passes, else it fails and reports.
require 'minitest/autorun' class TestExample < Minitest::Test def test_sum assert_equal 4, 2 + 2 end end
| Step | Action | Evaluation | Result |
|---|---|---|---|
| 1 | Run test_sum method | assert_equal 4, 2 + 2 | Check if 4 == 4 |
| 2 | Evaluate condition | 4 == 4 | True |
| 3 | Test result | Pass | No error raised |
| 4 | Report | Test passed | Output success message |
| 5 | End | All tests done | Exit |
| Variable | Start | After Step 1 | After Step 2 | Final |
|---|---|---|---|---|
| expected | 4 | 4 | 4 | 4 |
| actual | undefined | 2 + 2 | 4 | 4 |
| assertion_result | undefined | undefined | true | true |
Minitest uses assert methods to check conditions. assert_equal(expected, actual) tests equality. If true, test passes silently. If false, test fails with error. Tests are methods inside classes inheriting from Minitest::Test. Run tests with 'ruby filename.rb'.