UnitTest Problem

I enter three integers with the aid of a form into the database (I
believe it is :post). In the controller, I make some calculations with
the numbers and save this in the database. The method in the controller
is called “create_index”

How can I test the calculation ? Is that a unit or functional test ?
Because I would like to test the calcualtion, if the results are
correctly saved in the database.

Thanks for your help !

M. R. wrote:

I enter three integers with the aid of a form into the database (I
believe it is :post). In the controller, I make some calculations with
the numbers and save this in the database. The method in the controller
is called “create_index”

How can I test the calculation ? Is that a unit or functional test ?
Because I would like to test the calcualtion, if the results are
correctly saved in the database.

Can anyone help me ???

I believe the rule is: if you’re testing a method of a model, use a unit
test; if you’re testing a method of a controller, use a functional test.

M. R. wrote:


Lance I.
Web Applications Developer
RBS Interactive
[email protected]

On 10/18/06, M. R. [email protected] wrote:

I enter three integers with the aid of a form into the database (I
believe it is :post). In the controller, I make some calculations with
the numbers and save this in the database. The method in the controller
is called “create_index”

How can I test the calculation ? Is that a unit or functional test ?
Because I would like to test the calcualtion, if the results are
correctly saved in the database.

I’m guessing that the calculation should be performed by the AR model,
rather than in the controller directly. If you did this then it’d be
very easy to unit test the model in isolation.

If you knew that the model was calculating correctly then you could
use a mock object in your functional controller test to make sure that
the calculate method is being called.

Chris