Which test names do you prefer?
"tong() method can connect to database"
"tong() method can disconnect from database"
"sha() method can delete an existing file"
"sha() method fails when deleting a non-existing file"
or:
"tong 1"
"tong 2"
"sha 1"
"sha 2"
They are both rather extreme, but if I had to choose, I would still rather go with the shorter ones. I tend to treat test names more like unique IDs, and when things go wrong I just look up the actual test code.
I wouldn't mind verbose test names though if they can somehow be automatically generated (a future Google Translate project, perhaps?) from code, because they are just repeating what the code says.
To repeat myself, it's the DRY principle.
Kamis, 11 Maret 2010
Langganan:
Posting Komentar (Atom)
I tend to prefer more verbose test labels, but I also tend to parameterize my tests so that the label is generated from data.
BalasHapusfor my $t ( @tong_tests ) {
my ($label, $args) = @$t;
ok( tong($args), "tong() method can $label");
}
That's sort of silly for just two cases, but once you start testing all sorts of inputs, it scales very nicely.
-- dagolden
@dagolden: Yup, I use data for test labels all the time :-)
BalasHapus