6. Complessità
You might think of this as mental juggling - the more mental
balls the program requires you to keep in the air at once, the
more likely you’ll drop one of the balls, leading to a design or
coding error.
-- Steve McConnell
8. Test?
«Testing by itself does not improve software quality. [...]
Trying to improve software by increasing the amount of testing
is like trying to lose weight by weighting yourself more often»
-- Steve McConnell
9. Test!
• Aumenta indirettamente la qualità del
software
• Design for testing
• Refactoring
• Wishful thinking
• Confidenza con il proprio codice
10. Esempio
#!/usr/bin/perl -w
use Test::Simple tests => 2;
use Date::ICal;
my $ical = Date::ICal->new; # make an object
ok( defined $ical ); # check we got something
ok( $ical->isa('Date::ICal') ); # and it's the right class
22. WWW::Mechanize::Shell
#!perl -w
use strict;
use WWW::Mechanize;
use WWW::Mechanize::FormFiller;
use URI::URL;
my $agent = WWW::Mechanize->new( autocheck => 1 );
my $formfiller = WWW::Mechanize::FormFiller->new();
$agent->env_proxy();
$agent->get('http://www.google.com');
$agent->form(1) if $agent->forms
and scalar @{$agent->forms};
mech3.pl
27. Idee
• Usare proxy.pl con un sistema di bugtracking
(il ticket contiene il codice per riprodurre
l’errore)
• Testare applicazioni non scritte in Perl
• Screenscraping
28. Conclusioni
• Integrate le pratiche di testing nel vostro
workflow lavorativo
• Gradualmente!
• Sono pratiche che pagano da subito
• Come posso progettare il codice per
facilitarne il test?
29. Monday, I could wait till Tuesday
If I make up my mind
Wednesday would be fine, Thursday’s on my mind
Friday’d give me time, Saturday could wait
But Sunday’d be too late
-- Sting
30. Grazie :)
larsen@perl.it
http://larsen.perlmonk.org/blog
31. Riferimenti
• Web Testing with HTTP::Recorder
http://www.perl.com/pub/a/2004/06/04/recorder.html
• Test di applicazioni web
http://www.perl.it/blog/archives/000036.html
• A Perl Testing Tutorial (PDF)
http://www.wgz.org/chromatic/perl/IntroTestMore.pdf
• Migliorare la navigazione sul web con Perl
http://www.perl.it/blog/archives/000076.html
• Documentazione dei vari moduli menzionati
http://search.cpan.org/