Thursday, May 8, 2008

Unit Testing

In the couple of projects i worked on, i tried to use nunit but failed miserably. All the applications i tried were typical asp.net applications (3-tier) and i had a lot of difficulty in writing test cases to test the methods which return collections and in testing UI events. UI events include checking whether a particular field/set of fileds are updated and with correct data upon some action by user. I thought it has something to do my knowledge of using nunit OR nunit supports testing of components and not UI events or methods returning collections.

The problems i faced (in testing methods that return collections based on filter criteria)
1) I have to write the data retrieval methods to fetch data from DB to check against the method being tested. So, there could be error in writing the code to fetch data directly from DB.
2) Once a method is tested, i have to restore the data to previous state to test the same method again. i think this is necessary for repetitive testing.

I discussed the same with my colleagues but didn't get a satisfied answer. Thanks in advance for providing me any links to useful posts on the topic.