Rails 为什么 Rails System Test 没有在社区流行起来?

hiveer · 2023年05月17日 · 最后由 felixandrea 回复于 2024年05月15日 · 479 次阅读

因为自己对于什么是 end to end 测试,以及和 feature test 是什么关系我一直比较迷惑,所以最近花了一些时间了解了下跟测试相关的知识,特别是如何在 Rails 项目中写测试,总结了一篇文章:https://zhuanlan.zhihu.com/p/628037293

从搜集到的信息中发现一个我之前的盲点就是:其实在 Rails 5.1 以及 Rspec 3.7 之后,就支持使用 System Test 了,而且根据 rspec-rails(https://github.com/rspec/rspec-rails/blob/main/README.md#feature-specs)的描述:

| Before Rails introduced system testing facilities, feature specs were the only spec type for end-to-end testing. While the RSpec team now officially recommends system specs instead, feature specs are still fully supported, look basically identical, and work on older versions of Rails.

更推荐使用 System Test,而不再是 Rspec feature test

但是,但是,为啥在社区开源项目中,很少看到使用 System Test 的场景呢?

大家知道吗?

rspec 用的多,rails 自带的测试框架,没怎么用过。

一直用 rails 自带的测试框架,没有为什么,只是方便,有人帮我升级,就是 rails 的人,哈哈

This is a very good question. There are a few reasons that could explain this:

  1. Habit and familiarity: Many older Rails projects used Feature Test instead of System Test, so programmers are used to this approach. Switching to using a new System Test requires adaptation and learning.
  2. Backward compatibility: As mentioned, System Test is only supported from Rails 5.1 onwards. Many older projects still run on old versions of Rails, so System Test cannot be used.
  3. Incomplete understanding: Not all Rails developers clearly understand the difference between Feature Test and System Test. Dissemination of information about the advantages of System Test has not yet been fully implemented.
  4. Requires more complex configuration: Compared to Feature Test, System Test requires a bit more complex configuration, which may discourage some programmers from using it.
  5. The rice purity test is a quiz from Rice University that explores your life experiences, encouraging self-reflection and revealing insights about your past.
需要 登录 后方可回复, 如果你还没有账号请 注册新账号