🙋 Minitest users, I need your feedback on Hanami’s upcoming Minitest support! https://discourse.hanamirb.org/t/feedback-on-hanami-minitest/1415

#ruby #minitest

Feedback on Hanami Minitest

Hi everyone — I’m pleased to share that our initial Minitest support is now merged into the gem’s main branch. I’ve implemented the block-based test/setup/teardown API, as you suggested above (with some tweaks to make it fit better with setup and teardown methods in superclasses). I decided to host the base classes inside the gem. They exist as Hanami::Minitest::{Test,RequestTest,FeatureTest}. I’ve also take the opportunity to use this as a first foray into internalising some of the test setup...

Hanami
@timriley If you need any help integrating with Mocha, let me know - I’d be happy to help
@floehopper Thank you! 😊 Is Mocha a pretty standard part of a Minitest user's toolkit? Maybe we should include it out of the box?
@timriley I’m not sure that’s true - Minitest used to come with a simple mock implementation although it looks like it’s been split out in into minitest-mock now.
@floehopper @timriley Mocha has a much nicer API in my experience. Minitest mock had always felt like a mocking framework designed to discourage mocking. Which, to be fair, might be true.

@eightbitraptor @floehopper @timriley I can confirm, minitest-mock is really the bare minimum, not something you want to use extensively.

Mocha is definitely the standard mock framework for minitest test suites.

But I also agree is potentially for the best that mocking has a bit of extra friction, as there is nothing worse than a test suite that is too heavily mocked/stubbed.

@timriley @floehopper @eightbitraptor it was. Not mocking is better than mocking for 80-90% of all tests.

@zenspider @timriley @eightbitraptor

> It was

Interesting!

> Not mocking is better than mocking for 80-90% of all tests.

I'm not going to bite! 😃

@floehopper @zenspider @timriley "we designed this screwdriver to be hard to use because not using screws is better than using screws 80-90% of the time"
@eightbitraptor @floehopper @timriley Your analogy only works because you're supposed to be welding, not screwing.
@eightbitraptor @floehopper @timriley "man... this screwing car parts together is really painful! we should make a better screwdriver!"
@zenspider @floehopper @timriley your reply has highlighted the main point I was stealth making tho - this kind of absolutist nonsense has no place in these kind of discussions because they remove all the context.
@eightbitraptor @floehopper @timriley let me know when you discover the absolutism

@zenspider @floehopper @timriley

> Not mocking is better than mocking for 80-90% of all tests.

Found it!

@eightbitraptor @floehopper @timriley Absolutist: a person who holds absolute principles in [...] matters
Absolute: not qualified or diminished in any way; total

try again

@zenspider @floehopper @timriley I'm not going to sit here and argue with you about word definitions, it's dull. You made a blanket statement that a whole class of programming techniques is inferior to another in 80-90% of cases, without qualifiers or context. I think you're wrong and that making statements without context or qualifiers is a form of bad faith argument.
@eightbitraptor @floehopper @timriley 🫡 Cool story. I've given plenty of context and qualifications. I don't feel like repeating myself esp on such a shitty medium.
@timriley @floehopper my two cents: many people will need or want the more powerful mocking tool. the people that have strong opinions about not using mocks much can still use minitest mocks or just not use mocha much in their tests.
@timriley @floehopper Hanami's dependency injection looks like something that could replace the need for mocking altogether
@timriley I use Minitest for everything ruby-off-work, and I missed just one tiny bit from rails-minitest, I have added a comment ( https://github.com/hanami/hanami-minitest/pull/3#issuecomment-3938540112 ) to your PR. I hope you like it.
Get started by timriley · Pull Request #3 · hanami/hanami-minitest

Minitest support for Hanami apps. Contribute to hanami/hanami-minitest development by creating an account on GitHub.

GitHub

@timriley FWIW, I've found providing a mix-in module to be a reasonable alternative to struggling with base class names. For example:

# frozen_string_literal: true

require "test_helper"

class TestHelloWorld < Minitest::Test
include Rooibos::TestHelper

def test_it_exits_with_ctrl_c
with_test_terminal do
inject_key(:ctrl_c)
Rooibos.run(HelloWorld)
assert true, "Should reach this point without hanging."
end
end
end

@kerrick @timriley I would suggest subclassing from your own test subclass, eg Hanami::Test, and have FeatureTest et al in the same namespace