Class::DBI Testing Testing Class::DBI - Facilitating "Best Practices" #13

4. Write tests that create and destroy all their own data

# Later on in Music::CD...

=begin testing

ok(my $artist = Music::Artist->create({
  name  => "The Nihilist Spasm Band"
}), 'create test Artist');

ok(my $cd = Music::CD->create({
  title   => "The Sweetest Country This Side of Heaven",
  year    => 1967,
  artist  => $artist
}), 'create test CD');

# Make sure relationships work
is_deeply($cd->artist, $artist, 'CD->Artist');
my @cds = $artist->cds();
is_deeply($cds[0], $cd, 'Artist->>CD');

# ...etc.; delete when finished:

$artist->delete
$cd->delete

=end testing
Copyright © 2004 Dan Friedman