[clug] PSIG last night

Alex Satrapa grail at goldweb.com.au
Sun Nov 16 22:18:19 GMT 2008

On 15/11/2008, at 10:12 , Michael Cohen wrote:

> I also think its important for a unit test to start with a blank
> slate, and reach the tested condition.

The Python and Django unit testing frameworks do this. Setup and  
teardown functions are run for each unit test.

> Also important is to manage a set of test data - this is the most
> important because you dont want anything too big, or that setup phase
> will take too long, but you want something fairly representative of
> real data.

It's also important to remember that once you have test data that is  
valid, you never get rid of it. As your application evolves, you're  
going to come across cases where data exists in production databases  
which is no longer valid according to your new rules.

Either you massage the data to be "valid" by your new rules, or you  
massage the rules to allow the old "invalid" data. Python and Django  
provide for fixtures to be loaded from YAML or JSON. Sample data  
should be kept in the source code repository along with your code. Any  
change to the schema should include any data massaging routines (for  
the actual migration), along with additional fixtures to provide new  
sample data for the "currently valid" ruleset.

Eternal vigilance is required when dealing with data structures/ 
relationship rules that change over time.


More information about the linux mailing list