~/talk

Writing a Test Framework From Scratch

Talkat MountainWest RubyConf 2016 · 2016-03-21..03-22· [testing]
slides:none on file

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

  1. 0:00Intro
  2. 0:48Making a Test Framework from Scratch
  3. 2:09Introduction
  4. 2:27Code Walkthroughs?
  5. 3:01Learn Nothing
  6. 4:15Starting From Scratch
  7. 4:39NOT Minitest
  8. 5:07Experiment & Understand
  9. 5:20Start with the Assertion
  10. 5:40Test framework: complete.
  11. 6:16Tradeoffs
  12. 7:32def assert test raise RuntimeError, "Failed test", caller unless test
  13. 8:42Filter Backtrace
  14. 9:43The Rule
  15. 10:26Simply works!
  16. 10:42Exercise for You
  17. 11:04Wrap: Assertions in a Test
  18. 11:21Prioritization
  19. 11:45Pro: Separate Blocks
  20. 12:39Use Methods
  21. 12:51Just Use Ruby
  22. 14:36Group Methods
  23. 15:00Cumbersome
  24. 15:14Setup & Teardown?
  25. 15:32Reflection & Filtering
  26. 16:00Push Up Refactoring
  27. 16:24Subclass Test
  28. 16:47Auto-Register Tests
  29. 17:47Silence is Golden
  30. 17:57Trust, But Verify
  31. 19:01st Failure : Done
  32. 19:33Fixing A Mess, aka Refactoring
  33. 19:54Push Down: Exception Handling to Instance Method
  34. 20:16Break Up Responsibilities
  35. 21:00Run method handles exceptions
  36. 21:14Extract: IO to Class Method
  37. 21:51Removed all 10 from Test
  38. 22:10Quick Fix
  39. 22:46rd Argument
  40. 22:57Pass Anything!
  41. 23:392 arguments
  42. 24:12Mixed Types
  43. 25:21Separate overview & details
  44. 26:27Add: Test Randomization
  45. 26:43Tests should always pass regardless of what was run, what order they were run in, or anything else.
  46. 28:07slides / 2 loc ?!?!
  47. 28:31Run One Test
  48. 28:43Failure Handling
  49. 29:06Sample Chapter Coming Soon!
  50. 29:24Questions?
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.