2/26/2023 0 Comments Terminal notifier guardUnfortunately these conventions have changed recently, so I found myself getting conflicting suggestions from various places online. Minitest itself does not care how you organize or name your tests, but the Rails ecosystem uses a certain set of conventions. The directory structure is not immediately obvious. 2 Luckily I discovered the minitest-reporters gem, which does everything I need (including a nifty progress bar). Surprisingly, the tutorials I found for Minitest did not address this. Minitest makes a bad first impression, because its default output on the console is pretty bland: no color! This is something I took for granted as an RSpec user. Minitest’s default output is a step backwards. My reasoning: if I wanted to write BDD style, I’d just stick with RSpec! I am only concerned with the assertion style, since that is what is promoted by Rails itself, and is what differentiates Minitest from RSpec. Minitest is a single testing framework, but it ships with two completely different DSLs: the “assert” (or “xUnit”) style DSL and the BDD (behavior-driven development) style. Pay close attention to the publication date and the Rails version referenced to make sure those gems and recommendations are still applicable. If you search the web and come across blog posts, Stack Overflow answers, or gems that refer to Test::Unit, they are probably talking about Rails 3 and below. 1 Just be assured that if you are using Rails 4 or higher, then “test unit” simply means Minitest, with some Rails-specific syntactic sugar sprinkled on top. Starting with Rails 4, the core functionality and assertions were replaced by Minitest, but confusingly, in some places the name “test unit” remains. Test::Unit was the name of the default Rails testing framework up through Rails 3. TestUnit and Minitest are the same thing… except not. If you decide to jump on the Minitest bandwagon, you’ll probably run into these gotchas too. Actual Minitest output from one of my recent Rails projects. Tl dr – Jump straight to the code recommendations. But when it came time to actually setting up my Rails project, I found Minitest+Rails documentation to be outdated or lacking. Minitest seems to be enjoying a spike in popularity my interest was piqued by Brandon Hilkert’s article, 7 Reasons I’m Sticking with Minitest and Fixtures in Rails.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |