Thoughts about Rails testing and debugging
Good and well-covered unit tests prevents breaking changes and helps refactoring in the future.
In this article, i will write up some tips and thoughts about unit testing in Ruby on Rails development. I hope you find some of them helpful.
Fail fast is very useful when doing TDD (Test Driven Development), or when there are a bunch of failed tests need to be fixed one by one. Instead of running all your test suites, fail fast will abort once your test runner fails to pass one test suite. It saves time and let you focus on single problem.
Rails 5 has shipped fail fast feature for you, simply use
rails test -f or
rails test --fail-fast to enable fail fast option.
For older versions, you can try minitest-fail-fast gem. Notice that i did not check if minitest-fail-fast is still working, you can figure it out by yourself.
m: run single test by line number
If you have used...
Continue reading →