Re: beginning and testing

Jon <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CAL40zrSCZyZUO2dzT8mcM06rWOnyoNbnYJj-kNhxVgwsnCe4eA@mail.gmail.com>
Hello Bill,

Apache::Test is great.

What kind of testing are you looking to do?  Apache::Test is for testing
your code (unit tests) and JMeter is for load testing your application /
infrastructure (in my organization we classify this under UAT which the
developers don't do).  I agree with Mark that with the technology we have
today, manual testing causes more problems than it solves... while setting
up times may be a bigger initial time investment, automated tests really do
save time.

Have you looked at any of the Perl Web Frameworks?  Catalyst
<http://www.catalystframework.org/>, Dancer <http://www.perldancer.org/>,
and Mojolicious <http://mojolicio.us/> all use Plack middleware (which
interfaces nicely with mod_perl or any webserver; Mojo can use
Server::Hypnotoad <http://mojolicio.us/perldoc/Mojo/Server/Hypnotoad>, a
non-blocking web server, then uses Apache as a reverse proxy to serve your
web page.  The advantages and disadvantages of which I think are outside
the scope of this thread), and they come with their own testing suits,
Catalyst::Test
<http://search.cpan.org/~jjnapiork/Catalyst-Runtime-5.90075/lib/Catalyst/Test.pm>
 Dancer::Test
<http://search.cpan.org/~yanick/Dancer-1.3129/lib/Dancer/Test.pm> and
Test::Mojo <http://mojolicio.us/perldoc/Test/Mojo> which are great for unit
testing.  These days my testing stack is Test::More
<http://search.cpan.org/~exodist/Test-Simple-1.001006/lib/Test/More.pm>,
Test::Class
<http://search.cpan.org/~ether/Test-Class-0.47/lib/Test/Class.pm> and
Test::Mojo, I recommend Test::Class to anyone who's writing unit tests for
more than a few hundred lines of code.

I have been a long time user/fan of mod_perl, some of my longest running
apps are running on mod_perl right now.  But for new projects I've turned
to using a web framework as it allows us to focus on the app and not worry
about the boiler plate.  But that's me, there are plenty of valid reasons
NOT to use a web framework.

Good luck!

Best Regards,
Jon A


On Tue, Oct 7, 2014 at 11:42 AM, Mark Hedges <[email protected]>
wrote:

>
>
> -----Original Message-----
> From: Patton, Billy [mailto:[email protected]]
> Sent: Tuesday, October 07, 2014 6:24 AM
> To: [email protected]
> Subject: beginning and testing
>
> I'm rewriting/moving an app that hasn't been touched in over 5 years.  The
> original developers have since left the company.
> It's all written in CGI/OOPerl.
> It seems as though the original developers applied the OOW-AHH , look at
> what I can do, instead of KISS.
> Simply put they needed a skateboard but built a space shuttle.
>
> So I'm task with taking this Hydra/Medusa cross and converting it to
> KISS(Keep It Simple Stupid)
> So I'm going to us mod_perl.  I will be able to use some of their logic
> and code.
>
> At my previous job we had a mantra "design for test"
>
> So from the very first file I create I want to be able to test each step
> as I proceed.
> I've used, very simply, the .t files for test my library and my apps that
> run from the command line but never some thing from the web.
>
> In the past I've used an Oracle product that does web testing, but that's
> rather expensive.
> So have no doubts that Apache and mod_perl have an enormous testing suite
> available for testing my perl and the web site it creates.
> IE : Apache:TestRun, Apache::TestRunPerl
> When I do
> apropos Apache | grep -i test
> I get 14 Apache::Test* modules and one Bundle::ApacheTest module.
>
> So I'm looking for a start point.
> There is a lot of information, too much for me to digest.
> My web app will consist of forms with h-links to another page and some
> drop downs.
> A few "enter text" widgets.
>
> I'm beginning to believe that testing in Apache is a completely difference
> world than testing from the command line, as it should be.
>
> I'm just not sure where to start.
> Any recommendations would help.
> -------------------------------------
>
> I have found Apache::Test extremely useful for testing web applications.
> Don't let anyone tell you to run manual tests, that is a recipe for
> confusion and error as you try to modify code later.
>
> A good place to start is the test structure for mod_perl itself, but all
> the bells and whistles they use are probably more than you need.
>
> Also, I use Module::Build instead of ExtUtils::MakeMaker.  Follow the
> instructions for a Module::Build Build.PL file, but make your builder
> object an Apache::TestMB or subclass of that.  (It is a subclass of
> Module::Build.)
>
> Then you want to start with the files t/conf/extra.last.conf.in and
> t/conf/modperl_extra.pl.  extra.last.conf.in contains Apache directives
> and VirtualHost sections that you want to run.  modperl_extra.pl will be
> executed by Apache startup.
>
> When you do `./Build test`, it will generate t/TEST, start up Apache2 with
> your settings on a localhost port, then you can use LWP and start
> implementing tests.  I sometimes add a testing environment variable which
> causes my apache handlers to add extra results in an X- header to check in
> the test script.
>
> You can also write t/TEST.PL, which gets added to the generated t/TEST
> script.  It has to run:
>
>   use Apache::TestRunPerl ();
>   Apache::TestRunPerl->new->run(@ARGV);
>
> ... at the end, since this does not seem to get added to the generated
> t/TEST script when t/TEST.PL is used.
>
> HTH.
>
> Mark
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.