Ideally speaking, both. 1) is known as "unit" testing and is of the
greatest use to developers to ensure bits of code behave as expected. 2)
is known as "functional" or "acceptance" testing and is of
the greatest
use to end users and clients to ensure the project requirements are met.
For 2), I greatly enjoy http://wtr.rubyforge.org/.
Matthew Denner wrote:> Hi,
>
> I''m just wondering: how do people do their functional tests?
>
> I see two possible versions:
>
> 1. You test every controller, and every action, in isolation and with
> varying criteria. For example, you might have a
> ''test_login_with_valid_details'' and a
''test_login_with_invalid_details'';
> both test the same action but under different circumstances.
>
> 2. You test a much longer sequence of actions, which might be across
> multiple controllers, to ensure that you can ''login, create a
foobar,
> and logout''. These are more like testing a typical user
experience.
>
> I''ve gone with 1 purely because my brain works that way and I
don''t
> exactly see RoR handling testing multiple controllers very well (at
> least I haven''t seen any examples). I personally don''t
see these as an
> either-or choice, but rather that both should be present with 2 building
> on the knowledge from 1.
>
> I think I''m missing something, or confusing myself.
>
> Matt
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails