006. how to run a single test in rails 5 (minitest) - cwy007/tips-and-skills GitHub Wiki
# run in terminal
# test a single test example
rails test test/controllers/line_items_controller_test.rb:37
# test controllers, models ...
rails test:controllers
rails test:models
数字37
是指测试案例所在的行数--也就是test ’ should update product' do
所在的行数
reference link: https://stackoverflow.com/questions/1506780/how-to-run-single-test-from-rails-test-suite
✘ cwy@MPro ⮀ ~/agile-web-dev-with-rails/cwyfiles/work/depot ⮀ ⭠ master± ⮀ rails test --help
Running via Spring preloader in process 38115
Usage: bin/rails test [options] [files or directories]
You can run a single test by appending a line number to a filename:
bin/rails test test/models/user_test.rb:27
You can run multiple files and directories at the same time:
bin/rails test test/controllers test/integration/login_test.rb
By default test failures and errors are reported inline during a run.
Rails options:
-w, --warnings Run with Ruby warnings enabled
-e, --environment Run tests in the ENV environment
-b, --backtrace Show the complete backtrace
-d, --defer-output Output test failures and errors after the test run
-f, --fail-fast Abort test run on first failure or error
-c, --[no-]color Enable color in the output