Structuring Tests
Earlier we asked you to ignore the scaffolding around our tests. Now it’s time to look at it.
You include the testing framework facilities in your unit by including minitest/autorun.
| require "minitest/autorun" |
The minitest/autorun module includes minitest itself, which has most of the features we’ve talked about so far. It also includes an alternate minitest/spec syntax that’s more like RSpec and the minitest/mock mock object package. (We’re not going to talk about minitest/spec syntax in this book. If you want that style of syntax, we recommend actually using RSpec.) Finally, it calls Minitest.autorun, which starts the test runner. This is why our test files have been executing tests when invoked just as plain Ruby files. ...
Get Programming Ruby 3.3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.