0

suppose you want to test a test/controllers/static_pages_controller_test.rb

rails test test/controllers/static_pages_controller_test.rb

the results will be

(static-pages) $ rails test test/controllers/static_pages_controller_test.rb Running via Spring preloader in process 2430 Run options: --seed 45024

Running:

..

Finished in 0.900028s, 2.2222 runs/s, 2.2222 assertions/s.

2 runs, 2 assertions, 0 failures, 0 errors, 0 skips

  • Possible duplicate of [How to run single test from rails test suite?](http://stackoverflow.com/questions/1506780/how-to-run-single-test-from-rails-test-suite) – 3limin4t0r Apr 11 '17 at 11:57

1 Answers1

2

rails test method you have used run all unit, functional and integration tests. To run only a single test you can use invitation test as follows

 ruby -Itest test/controllers/static_pages_controller_test.rb 

You can also run a particular test method from the static_pages_controller_test by using the -n switch with the test method name as follows.

 ruby -Itest test/controllers/static_pages_controller_test.rb -n test_method_name

Hope this link will help you to get a better idea

Zabba
  • 64,285
  • 47
  • 179
  • 207
Tyesh
  • 370
  • 2
  • 12
  • While this code snippet may be the solution, [including an explanation](//meta.stackexchange.com/questions/114762/explaining-entirely-‌​code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. – Adam Apr 12 '17 at 15:01
  • @Adam thank you for your feedback. Hope my edit will work – Tyesh Apr 12 '17 at 15:22