On Ruby on Rails, how to run ONE functional test when another breaks?

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

 rake test:functionals 

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

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

+6
ruby-on-rails testing functional-testing
source share
3 answers

Answer Wise-Ass
If your colleague breaks the tests, then he should fix the test, or he should not have passed the code to the repo. This is the basic principle that we usually have in projects that I work on.

Good answer
try it

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

Or it’s the start of a single test without a rake, but with an explicit $ -load path it also works here "ruby -I directory" indicates the $ download path. Otherwise, you do not load the test environment and "require test_helper" fails!

 ruby -I test test/functional/xy_test.rb 
+10
source share

1) Perhaps: rake test: units

2) This link can also help you:

http://rake.rubyforge.org/

3) It can also help you:

"Typical Rails tests come in the following forms:

Unit (Model) These are the 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 like this.

Functional (controller) These tests are the individual actions of the controller in isolation.

Integration (controller to controller) These mutations of the test state between / over several actions and routing, i.e. ensuring that things don't explode completely when the user clicks through a typical workflow.

Fixtures Used to store an approximate model data used for models in tests, avoiding the tedious process of manually creating model objects.

Unit / Helpers These are the test helpers in the views.

In other words, the main relationship looks like this:

Unit Test Model Functional Testing Controller (as part of a) Functional Testing Controller for Controller Integration Test "

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

0
source share

Check out the single_test gem, which makes it easy to run specific tests (or test groups)

0
source share

All Articles