I have been organizing my test cases by a hierarchy of controller/action/scenario or model/method/scenario. It looks natural and clear. But I found I had to setup test data repetitively for different actions and methods for the same scenario. Although I can reduce code redundancy by code reuse. But I think it is still time-wasting especially for the machine to setup these test data again and again. Is there anybody organizing these test cases by scenarios? What is the best way of organizing test cases?
I have been organizing my test cases by a hierarchy of controller/action/scenario or model/method/scenario.
Share
If this question is about repeating yourself when generating test data you should probably look at the following gems that helps you generate test data:
If this question is about delay when running test, you should probably look at spork.
And if this question is about organizing test, one approach that I guess is quite common is to separate tests into unit tests and functional tests.
Tests all the methods, one by one, in unit tests. And tests all the scenarios in functional tests.
spec/unit/user_spec.rb
spec/functional/user_spec.rb