新手问题 看书《Ruby on Rails 5 Tutorial 4th》操作,运行 rails test,但是提示 0 runs,为什么测试没有跑起来呢?

yellowup · 2020年11月07日 · 最后由 yellowup 回复于 2020年11月07日 · 307 次阅读
Running via Spring preloader in process 161709
Run options: --seed 39189

# Running:

Run options: --seed 39189

# Running:



Finished in 0.005780s, 0.0000 runs/s, 0.0000 assertions/s.

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



Finished in 0.042032s, 0.0000 runs/s, 0.0000 assertions/s.
0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
1   require 'test_helper'
  1
  2 class StaticPagesControllerTest < ActionDispatch::IntegrationTest
  3   test "should get home" do
  4     get static_pages_home_url
  5     assert_response :success
  6   end
  7
  8   test "should get help" do
  9     get static_pages_help_url
 10     assert_response :success
 11   end
 12
 13 end

书中第 80 页,pdf98 页,是直接 $ rails test,我就又加上了文件名 $ rails test static_pages_controller_test.rb,也是一样的结果。

文件路径是不是错了

Awlter1 回复

没有错把,我 cd 到文件夹里面的

Awlter1 回复

解决了,的确是路径的问题,要回到根路径执行 rails test 就可以了。谢谢老哥。另外想请教下,为什么要到根路径才可以,是怎么个执行逻辑,直接指定了测试的文件名不可以吗

需要 登录 后方可回复, 如果你还没有账号请 注册新账号