~/talk

Writing a Test Framework from Scratch

Talkat RailsConf 2016 · 2016-05-04..05-06· [testing]
slides:none on file

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

  1. 0:00Making a Test Framework from Scratch
  2. 1:47Introduction
  3. 2:02Code Walkthroughs?
  4. 2:24minitest line by line
  5. 3:29Starting from Scratch
  6. 3:40Building Your Own Test Framework
  7. 3:55NOT Minitest
  8. 4:26Experiment & Understand
  9. 4:40Start with the Assertion
  10. 5:00Test framework: complete.
  11. 5:33Tradeoffs
  12. 6:53def assert test raise RuntimeError, "Failed test", caller unless test
  13. 7:50Unhelpful Failures!
  14. 8:09Filter Backtrace
  15. 9:11The Rule
  16. 10:25Exercise for You
  17. 10:41Wrap: Assertions in a Test
  18. 10:56Organization
  19. 12:41Use Methods
  20. 12:51Just Use Ruby
  21. 14:43Group Methods
  22. 15:24Setup & Teardown?
  23. 15:45Reflection & Filtering
  24. 16:22Push Up Refactoring
  25. 16:49Subclass Test
  26. 17:14MyTest Test
  27. 18:15Silence is Golden
  28. 19:46st Failure : Done
  29. 21:07Push Down: Exception Handling to Instance Method
  30. 21:32Break Up Responsibilities
  31. 22:11Run method handles exceptions
  32. 22:27Extract: IO to Class Method
  33. 23:40Quick Fix
  34. 24:09rd Argument
  35. 24:21Pass Anything!
  36. 24:32Record Failure
  37. 25:082 arguments
  38. 25:49Mixed Types
  39. 28:07Add: Test Randomization
  40. 28:29Rule of Testing
  41. 29:16Summary
  42. 29:58slides / 2 loc ?!?!
  43. 30:18Run One Test
  44. 30:30Failure Handling
  45. 30:59Sample Chapter Coming Soon!
  46. 31:14Questions?
~/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.