Writing a Test Framework from Scratch
summary
Claims how to build a test framework from the atom of assert up to runnable suites using plain Ruby, reimplementing minitest as “microtest” with real code: implements assert_equal and assert_in_delta (1/1000 tolerance), uses raise with caller to fix backtraces, isolates tests via methods and classes, records subclasses with the inherited hook, extracts IO to a Reporter, randomizes with shuffle, and ends with about 70 lines that run ~2x faster than minitest.
AI-written summary · about
chapters (46)
- 0:00Making a Test Framework from Scratch
- 1:47Introduction
- 2:02Code Walkthroughs?
- 2:24minitest line by line
- 3:29Starting from Scratch
- 3:40Building Your Own Test Framework
- 3:55NOT Minitest
- 4:26Experiment & Understand
- 4:40Start with the Assertion
- 5:00Test framework: complete.
- 5:33Tradeoffs
- 6:53def assert test raise RuntimeError, "Failed test", caller unless test
- 7:50Unhelpful Failures!
- 8:09Filter Backtrace
- 9:11The Rule
- 10:25Exercise for You
- 10:41Wrap: Assertions in a Test
- 10:56Organization
- 12:41Use Methods
- 12:51Just Use Ruby
- 14:43Group Methods
- 15:24Setup & Teardown?
- 15:45Reflection & Filtering
- 16:22Push Up Refactoring
- 16:49Subclass Test
- 17:14MyTest Test
- 18:15Silence is Golden
- 19:46st Failure : Done
- 21:07Push Down: Exception Handling to Instance Method
- 21:32Break Up Responsibilities
- 22:11Run method handles exceptions
- 22:27Extract: IO to Class Method
- 23:40Quick Fix
- 24:09rd Argument
- 24:21Pass Anything!
- 24:32Record Failure
- 25:082 arguments
- 25:49Mixed Types
- 28:07Add: Test Randomization
- 28:29Rule of Testing
- 29:16Summary
- 29:58slides / 2 loc ?!?!
- 30:18Run One Test
- 30:30Failure Handling
- 30:59Sample Chapter Coming Soon!
- 31:14Questions?
related talks
38mWriting a Test Framework from Scratch
32mWriting a Test Framework From Scratch
39mMiniTest: Refactoring Test Unit and RSpec back to version 0.0.1
40mA Guided Read of Minitest
32mMiniTest: Write Awesome Tests
32mA Big Look at MiniTest
33mRuby on Rails on Minitest
34mThe history of testing framework in Ruby
