Writing a Test Framework From Scratch
summary
Starts from assertions-first and implements assert (raising exceptions with caller-filtered backtraces), assert_equal, a float comparator using a 1/1000 delta, then builds tests as methods grouped in classes. Uses the inherited hook to auto-register subclasses, extracts a Reporter class that prints dots and Fs and stores failures, randomizes test order, and returns a clean summary. The result is a working minimal framework in about 70 lines of Ruby that runs quickly and shows all failures rather than stopping at the first.
AI-written summary · about
chapters (50)
- 0:00Intro
- 0:48Making a Test Framework from Scratch
- 2:09Introduction
- 2:27Code Walkthroughs?
- 3:01Learn Nothing
- 4:15Starting From Scratch
- 4:39NOT Minitest
- 5:07Experiment & Understand
- 5:20Start with the Assertion
- 5:40Test framework: complete.
- 6:16Tradeoffs
- 7:32def assert test raise RuntimeError, "Failed test", caller unless test
- 8:42Filter Backtrace
- 9:43The Rule
- 10:26Simply works!
- 10:42Exercise for You
- 11:04Wrap: Assertions in a Test
- 11:21Prioritization
- 11:45Pro: Separate Blocks
- 12:39Use Methods
- 12:51Just Use Ruby
- 14:36Group Methods
- 15:00Cumbersome
- 15:14Setup & Teardown?
- 15:32Reflection & Filtering
- 16:00Push Up Refactoring
- 16:24Subclass Test
- 16:47Auto-Register Tests
- 17:47Silence is Golden
- 17:57Trust, But Verify
- 19:01st Failure : Done
- 19:33Fixing A Mess, aka Refactoring
- 19:54Push Down: Exception Handling to Instance Method
- 20:16Break Up Responsibilities
- 21:00Run method handles exceptions
- 21:14Extract: IO to Class Method
- 21:51Removed all 10 from Test
- 22:10Quick Fix
- 22:46rd Argument
- 22:57Pass Anything!
- 23:392 arguments
- 24:12Mixed Types
- 25:21Separate overview & details
- 26:27Add: Test Randomization
- 26:43Tests should always pass regardless of what was run, what order they were run in, or anything else.
- 28:07slides / 2 loc ?!?!
- 28:31Run One Test
- 28:43Failure Handling
- 29:06Sample Chapter Coming Soon!
- 29:24Questions?
related talks
38mWriting a Test Framework from Scratch
32mWriting a Test Framework from Scratch
34mThe history of testing framework in Ruby
36mIt's not your test framework, it's you
34mEliminating Inconsistent Test Failures
28mTiny Tools Tidy Tests
36mIt's not your test framework, it's you
35mEvolution of a RESTful Testing Framework
