How to run a single test from a rails test suite?

后端 未结 12 1712
故里飘歌
故里飘歌 2020-12-07 09:09

How can I run a single test from a rails test suite?

rake test ANYTHING seems to not help.

12条回答
  •  独厮守ぢ
    2020-12-07 09:46

    Thanks to @James, the answer seems to be:

    rails test test/models/my_model.rb:22
    

    Assuming 22 is the line number of the given test. According to rails help:

     $ rails test --help
    

    You can run a single test by appending a line number to a filename:

        bin/rails test test/models/user_test.rb:27
    

    Also, please note that your test should inherit from ActionDispatch::IntegrationTest for this to work (That was my mistake):

    class NexApiTest < ActionDispatch::IntegrationTest
    .
    .
    .
    

提交回复
热议问题