views:

26

answers:

1

What steps should you use when in a need to write unit tests for STI associations. I am completely confused. Please provide some suggestions or links to some tutorials. Thanks in advance

A: 

There is absolutely nothing special in STI relationships that you should write test cases about. Since this is a functionality provided by framework, the frameworks comes with a bunch of testcases.

You only need to write testcases for the functionality you are building.

Swanand
@Swanand what if there is some code in the STI child classes i.e. methods that is being executed after the initialization of the class. I think it would be wise to test that code.
Rohit
Well yes, as I said, if you customized it, then you will need to run the built-in tests. Also, built-in STI modules will ensure the correct instance of class is loaded, depending on `type`, so if you are changing that, then you can write test case along those lines. My point being, there is nothing generic about STI. Post some code if you have any and we can take it from there.
Swanand
one of the child classes helps in uploading files another child class is used to store multiple choice answers. And there is a column "value" in the STI parent, where the name of the uploaded file is stored and also the choices selected by the user are saved in that column with each choice having its own record. Hope you have a better idea of the situation now.
Rohit