views:

25

answers:

2

let's say you added a controller and action (example: story/index), and want to run a functional test by

rake test:functionals

and then you found that another part of the project your coworker is working on actually broke the test at an earlier place (another controller/action), before your functional test takes place.

In this case, can you run just one functional test, which is yours?

+1  A: 

Wise-As Answer
If you coworker breaks the tests that he should fix the test or he shouldn't have commited the code to the repo, that is the main principle that we usually have in projects I work on.

Nice Answer
Try this

rake test:functionals TEST=test/functional/xy_test.rb

Or this
running one test without rake but with explicit $-loadpath works too here "ruby -I directory" specifies the $loadpath. Otherwise you won't load test environment and "require test_helper" fails!

ruby -I test test/functional/xy_test.rb
Jonas Söderström
thanks! the second one works -- for some reason the first one breaks...
動靜能量
A: 

1) Perhaps: rake test:units

2) This link might also help you out:

http://rake.rubyforge.org/

3) This might also help you out:

"Typical Rails tests come in the follow forms:

Unit (Model) These test business logic in your models. A well-written Rails application should have the bulk of its code in its models, so the bulk of your tests should be these.

Functional (Controller) These test individual controller actions in isolation.

Integration (Controller to Controller) These test state mutations between/over multiple actions and routing, i.e. ensuring that things don’t totally explode as a user clicks through a typical work flow.

Fixtures Used to hold example model data used to easily instantiate those models in tests, avoiding the tedious process of manually creating model objects.

Unit/Helpers These test helpers used in views.

In other words, the basic relationships look like this:

Model Unit Test Controller Functional Test View (as part of a) Functional Test Controller to Controller Integration Test"

Found at http://rails-nutshell.labs.oreilly.com/ch09.html

Brian T Hannan
unit test really is for testing models... functional is for testing controllers and views... they are the M V C in the MVC framework.
動靜能量