I propose we add hanami test
as a command to hanami/hanami
. We have rake
now, but I think this is a good nice-to-have.
I’m willing to commit to building it, once we come to consensus on the requirements.
Rationale
This allows users to run a single test file/test in an agnostic way (instead of using rspec
directly, e.g.)
It also signals that testing is a first-class concern of Hanami, appropriately.
Rails has this and it’s a nice convenience that I’ve used often. For reference, their defaults for just the test
command are that only non-system tests are run, which I think is a reasonable convention to follow.
Slices
I think that running hanami test
within inside the folder for a slice (or app/
) should only run the tests in that slice.
Question: Should running hanami test
in the main folder not only run tests in app/
but also run tests in the slices as well? I think so.
Regardless, we can also have an option to specify the slice from the main folder, e.g:
hanami test --slice admin
only run the tests for the admin slice, then also hanami test --app
can test just the main app (unless this is the default behavior, then it wouldn’t do anything).
Sub-commands
Looking at all the subcommands Rails has, I think we can get just implement a few key subcommands, as described below:
test Run all tests, except system tests
test:all Run all tests, including system tests
test:units Run tests in spec/actions, spec/models/, etc.
test:system Run all system tests
They also has test:db
which resets the DB before testing, which seems fine and useful but not sure it’s needed for v1.
Name
Question: Should we stick to calling it hanami test
and not support calling it hanami spec
at all? This would greatly simplify things, especially in documentation and for this reason, I think we should. It also leaves the spec
command namespace free for users to define as they wish.