What is the first test when developing a Perl CGI application using test-driven development?
We are looking to start a new project using Perl, the CGI::Application
module, and test-driven development.
Our question is: What should our first test be?
Should we test that our CGI::Application
subclass exists?
Should we test that /
returns a status of 200?
Should we tes开发者_运维百科t for something else?
I'd say that your application "business" logic should be implemented outside of the main CGI::Application module. That should be just responsible for the CGI interaction ie the 'view' and 'controller' parts of the MVC scheme.
So, I'd first write tests for the "business" logic classes and only after that I'd write tests for the cgiapp part. See here for the testing modules available for testing CGI::Application modules.
I have an experience with Test::WWW::Mechanize::CGIApp and can recommend it.
You should also look into Selenium, if you need to do more extensive UI tests that include testing javascript interaction.
Does it compile / does it have syntax errors?
That's usually done via a Test::More
test, like:
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use_ok('Your::App');
done_testing();
精彩评论