升级到 rails 5.2.0 后无法指定测试目录
Cannot specify directories for testing after upgrading to rails 5.2.0
我从 rails 5.1.1
升级到 rails 5.2.0
。我的过程如下:
- 升级了 rails gem 并解决了依赖性问题
- 查看了 railsdiff between 5.1.1 and 5.2.0 并根据需要更新了文件
一切看起来都运行良好,除了我注意到我的测试套件中有一些奇怪的行为
- 运行命令
rails test test/system
根本不是 运行我的系统测试。它 运行 我的所有其他测试(政策、服务、模型、工作),但不 运行 我的系统测试。
- 奇怪的是:运行宁一个特定的系统测试文件,例如:
rails test test/system/comment_test.rb
有效。
- 运行 特定的测试目录不再有效。例如,以前我可以 运行
rails test test/policies
、rails test test/models
和 rails test test/services
,它只会在这些目录中进行 运行 测试。这不再有效。相反,它只是 运行 的所有测试(系统测试除外)。
知道 rails 5.1.1
和 rails 5.2.0
之间发生了什么变化导致了这种行为吗?或者,也许我只是遗漏了什么?
根据 Rails Guides Testing Rails Applications: 2.7 The Rails Test Runner,它指出应该能够 运行 在每个目录的基础上进行测试:
You can also run an entire directory of tests by providing the path to the directory.
预期行为:
rails test
=> 运行 整个测试套件
rails test test/system
=> 运行系统目录下的所有测试
rails test test/models
=> 运行 只有模型目录中的测试
再现行为
我可以使用以下命令重现该行为:
rails new test_app # create demo app
cd test_app # cd into app
rails g scaffold user name # scaffold user
rake db:migrate # migrate
rails test test/system/ # Expect to run system tests but does not (scaffold creates 4 system tests)
从rails -T
您可以看到可用的任务。这个问题的两个相关问题是
rails test # Runs all tests in test folder except system ones
rails test:system # Run system tests only
从中可以看出rails test
不会运行系统测试。为此你需要 运行 rails test:system
, iirc 正确你可以 运行 所有测试 rails test:system test
我从 rails 5.1.1
升级到 rails 5.2.0
。我的过程如下:
- 升级了 rails gem 并解决了依赖性问题
- 查看了 railsdiff between 5.1.1 and 5.2.0 并根据需要更新了文件
一切看起来都运行良好,除了我注意到我的测试套件中有一些奇怪的行为
- 运行命令
rails test test/system
根本不是 运行我的系统测试。它 运行 我的所有其他测试(政策、服务、模型、工作),但不 运行 我的系统测试。- 奇怪的是:运行宁一个特定的系统测试文件,例如:
rails test test/system/comment_test.rb
有效。
- 奇怪的是:运行宁一个特定的系统测试文件,例如:
- 运行 特定的测试目录不再有效。例如,以前我可以 运行
rails test test/policies
、rails test test/models
和rails test test/services
,它只会在这些目录中进行 运行 测试。这不再有效。相反,它只是 运行 的所有测试(系统测试除外)。
知道 rails 5.1.1
和 rails 5.2.0
之间发生了什么变化导致了这种行为吗?或者,也许我只是遗漏了什么?
根据 Rails Guides Testing Rails Applications: 2.7 The Rails Test Runner,它指出应该能够 运行 在每个目录的基础上进行测试:
You can also run an entire directory of tests by providing the path to the directory.
预期行为:
rails test
=> 运行 整个测试套件
rails test test/system
=> 运行系统目录下的所有测试
rails test test/models
=> 运行 只有模型目录中的测试
再现行为
我可以使用以下命令重现该行为:
rails new test_app # create demo app
cd test_app # cd into app
rails g scaffold user name # scaffold user
rake db:migrate # migrate
rails test test/system/ # Expect to run system tests but does not (scaffold creates 4 system tests)
从rails -T
您可以看到可用的任务。这个问题的两个相关问题是
rails test # Runs all tests in test folder except system ones
rails test:system # Run system tests only
从中可以看出rails test
不会运行系统测试。为此你需要 运行 rails test:system
, iirc 正确你可以 运行 所有测试 rails test:system test