angular 的短板, rails 中UT的长处?( angular unit test v.s. rails UT's render_view)
访问量: 3109
用angular 做了3个项目(一个自己做,另外两个我带着项目组中其他人做)。 遇到的问题是: ( after 3 projects using angular, we met this problem: )
随着项目的增长,自动化测试(单元测试/功能性测试) 越来越重要。 对model的测试不多, 因为model仅仅是对DB的封装。 而且没啥太多逻辑。 逻辑都集中在 lib 中(rails), 出问题的地方主要集中在controller, view中。 ( in Rails, it's very easy to write an automation test testing both controller and view. but in Angular, because of the complete decouple, we have to write 2 kind of unit tests separately. )
因为angular跟 后台程序解藕特别好,所以 无法运行一个测试,就又测angular, 又测后台接口。
而RAILS就很简单了。 一个render_views 就可以 从controller 测试到 view. 例如: (this is the rails' code: )
# -*- encoding : utf-8 -*- require 'spec_helper' describe PlansController do render_views before do request.env["HTTP_REFERER"] = root_path @plan = create(:plan) end it 'should get index' do get :index end end
所以,目前看来,RAILS 这边还是很超前的。 耦合性虽然比 ANGULAR的大一些,但是从杠杆的角度讲,同学们觉得 使用RAILS更舒服一些,也容易坚持写单元测试(自动化测试) ( as a concolusion, I think rails unit test is preferred by Chinese coder like us: we don't have the Agile environment and Agile management, so maybe rails is more suitable for us ? )