A very interesting problem i came about yesterday was when i was trying to create unit tests for one of the Model classes of my mvc, its not actually a real model .....its a model that is base on another model . to make thinkg clearer i will describe whats happening :
The main model class is essentialy a table that has columns, this is what everything else in the app is building things upon; one of these things a representation of a plate, which will build its self upon data in the table. I would like to unit tet all the public functions in this class. in particular a the most basic function that take a table as a parameter, and construct the plate model elements accordingly. now this is where i ran into trouble, i wanted to make a factory class that will produce different tables ( taken into consideration some arguments) so i can pass them to the function and then i can comapre the structure to what its supposed to be ...... this all seems reasonable but this required me to actually write code to do the trasnformation too .
so think of the model class that i wanna test as a 2d integer array. i wanna test a funtion that will take in the table and build this 2d array out of it . so i need to write code ( if i wanna keep it generic) to take a 2d array, and give me a table, which then i will pass along to the function i wanna test, and then assert the result ...... well thats a circular problem. so i have decided i wanna go with prepeared test cases, mainly text files . this way i will know what kind of 2d array they should produce . i will have to write a parser which should resemble the Data Import i have.