English 中文(简体)
铁路局(TDD)
原标题:TDD in Ruby on Rails?

我想知道,如何在铁路进行TDD。

我在此阐述的步骤如下:

  1. Create migrations and models for the database tables
  2. Add associations to the models
  3. Write unit tests for the models and run and see them fail
  4. Add validations to the models
  5. Run tests and see them pass, if not, edit the code till they pass
  6. Create routing, controllers and views (that uses the models)
  7. Write functional tests
  8. Run tests and see them fail
  9. Edit code and see them pass
  10. Write integration tests

我以前从未做过TDD。

这是我所铭记的,但我首先要与你核对。

当然,这只字眼“正确”,我错过一些东西,有点不正确。

如果按照最佳做法看,情况不好,请更正上述清单。

交流经验!

最佳回答

如果认为存在某种误解(或者我是否误解?) TDD并不意味着“首先写所有法典,然后写所有测试”。 同你的申请一样,通过零敲碎打,测试也随之增加。

This might be a good place to get some practical examples:
http://andrzejonsoftware.blogspot.com/2007/05/15-tdd-steps-to-create-rails.html

on comment
So I should create tests before I create models and migrations?
See the definition: http://en.wikipedia.org/wiki/Test-driven_development
Test-driven development (TDD) is a software development technique that relies on the repetition of a very short development cycle: first the developer writes a failing automated test case that defines a desired improvement or new function, then produces code to pass that test and finally refactors the new code to acceptable standards.

虽然我个人认为,在第一次测试之前制造应用卡,没有什么错误。 更重要的是a 非常短的发展周期。 你们每天不戴上手法,并花在第二天进行检测。 你同时这样做。

问题回答

我亲眼学习铁路,并努力抓住TDD。 我已经找到了这一关于我所想购买的话题的屏幕:





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签