From: "David A. Black" Date: 2009-01-12T00:52:20+09:00 Subject: Re: reccommended work flow for unit tests and databases in ruby Hi -- On Sun, 11 Jan 2009, Adam Akhtar wrote: > How does one go around creating unit tests for database tables during > developement. Is there a rock solid work flow plan that everyone uses. > Im new to dbs and relatively so with unit tests. I have my project and > it usually starts with a rough idea of what fields need to be in the > table. As i code away items in the db change so it makes it difficult to > write unit tests that will withstand these changes. > > I know i need a test version of a database with static items but what id > like to do is for this test version to always reflect whats happening in > the development one. So if I add a field in the development one, the > test one gets one too. > > I could just go and code this and probably get something that works but > is probably ugly. I dont like to reinvent the wheel, a bad one at that > so if anyone has some tips or pointers in the right direction id really > appreciate it. > > This is for small projects so it doesnt have to industrial strength > bullet proof ninja stuff, small but elegant will be good enough Rails has a bunch of Rake tasks that copy the schema from one database to another. I don't know whether your project is a Rails application, but even if it isn't, you might be able to integrate one of those fairly easily, so that when you run your tests, the test database will pick up any changes in the development database. David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) http://www.wishsight.com => Independent, social wishlist management!