title: How can I automate testing for my database driven function?
body: <p>I'm trying to improve the automated testing in my application, but am unsure of the best way to proceed.</p>
  
  <p>My app gathers data from multiple forms, recodes it and stores it in a database.  I have created a pretty complex SQL view, which flattens the structure out, so it can be imported into a stats package (SPSS).</p>
  
  <p>My concern is that the view is complex, and I want to automate some tests around it.</p>
  
  <p>Currently I have some functional tests, which create a complete form objects model, and sends it into the application.  I then retrieve the view from the database, and use reflection to test that the retrieved view fields match the original data.  </p>
  
  <p>The problem is that this is very manual and heavy, my fixtures are lengthy, and it is cumbersome to add new scenarios (i.e. various parts of the model incomplete).</p>
  
  <p>Does anyone have any advice on how I could improve my test strategy?  Tips tricks all welcome!</p>
  
  <p>Thanks!</p>