You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Patton, Billy" <Bi...@h3net.com> on 2014/10/07 15:23:58 UTC

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.

RE: beginning and testing

Posted by Mark Hedges <Ma...@Ticketmaster.com>.
-----Original Message-----
From: Paul Johnson [mailto:paul@pjcj.net] 
Sent: Tuesday, October 07, 2014 12:39 PM

On Tue, Oct 07, 2014 at 08:23:58AM -0500, Patton, Billy wrote:
> I’m just not sure where to start.
> Any recommendations would help.

I'm going to give you some different, and perhaps somewhat heretical
advice.

You want to keep things simple.  That's great.  Your current application
doesn't use mod_perl.  So perhaps to keep things simple you don't need
to now.  mod_perl is a heavyweight solution.  I would suggest looking at
a lightweight framework instead, perhaps Dancer or Mojolicious.
...

--------------------------------------------------

I disagree about mod_perl being "heavyweight," or I don't understand
what you mean by the term.  Using mod_perl is the lightest "weight" 
you can get with a Perl web application -- the fewest number of function 
calls between the request and the response.

Mark


Re: beginning and testing

Posted by Paul Johnson <pa...@pjcj.net>.
On Tue, Oct 07, 2014 at 08:23:58AM -0500, Patton, Billy wrote:
> I’m just not sure where to start.
> Any recommendations would help.

I'm going to give you some different, and perhaps somewhat heretical
advice.

You want to keep things simple.  That's great.  Your current application
doesn't use mod_perl.  So perhaps to keep things simple you don't need
to now.  mod_perl is a heavyweight solution.  I would suggest looking at
a lightweight framework instead, perhaps Dancer or Mojolicious.

Then I would keep the parts that deal with the web as thin as possible.
Put anything not dealing specifically with the web into separate
modules.  Those modules can be tested extensively in the usual fashion,
and the web layer should be so thin that it's hard to have bugs in it.
However, both Dancer and Mojolicious have testing modules for those
parts too.

-- 
Paul Johnson - paul@pjcj.net
http://www.pjcj.net

Re: beginning and testing

Posted by Vincent Veyron <vv...@wanadoo.fr>.
On Tue, 7 Oct 2014 08:23:58 -0500
"Patton, Billy" <Bi...@h3net.com> wrote:
> 
> So from the very first file I create I want to be able to test each step as I proceed.


Hi Billy,

I find that building a test application for a Web app is not easy.

You have to code sample requests, and process the result to see if it matches what you expect; then all code changes made in the application must be accounted for in the test suite. It gets complicated fast.

If your application is indeed simple, you might be better off with a checklist of features to validate manually. After a while, you can look into automating it.



-- 
					Regards, Vincent Veyron 

https://libremen.com/ 
Legal case, contract and insurance claim management software

Re: beginning and testing

Posted by Adam Prime <ad...@utoronto.ca>.
I'd start by reading this:

http://perl.apache.org/docs/general/testing/testing.html

I'd then suggest taking a look at some of the popular mod_perl modules, 
and check out how their test suites work. Most of the stuff you're going 
to find there will be very unit test specific.

If you want to do functional application testing you'll need to use one 
of the various headless browser emulators out there (htmlunit, selenium, 
phantomjs) to do that, but many of them can be driven through the perl 
test harness one way or the other.

Adam


On 14-10-07 09:23 AM, Patton, Billy wrote:
> 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.
>


Re: beginning and testing

Posted by John Dunlap <jo...@lariat.co>.
That is heavily dependent on the architecture of your application but,
architecture permitting, this is why you need to have different types of
tests. In my case, I work with a SOFEA(Service Oriented Front End
Architecture) which is the formal way of saying that I have a
html/javascript front end which talks to HTTP/REST/JSON web services via
Ajax calls which originate from a web browser. In this kind of
architecture, for example, you can create integration tests which test the
end-to-end behavior of your system between the web service client(a web
browser in this case but could just as easily be an iphone) and all of the
server-side components all the way down to your data store(usually a
relational database) and back again. Unit tests, by contrast, are generally
for testing isolated behavior within a small subset of your code base.
Automated user interface testing, by contrast, is an entirely different(and
very complicated) topic requiring entirely different tools. This kind of
testing isn't simply concerned with the UI behaving correctly but also with
verifying that it behaves correctly in as many browsers, operating systems,
and browser versions as possible. I've previously used tools like Selenium
for this kind of testing with great success.

On Tue, Oct 7, 2014 at 5:31 PM, Vincent Veyron <vv...@wanadoo.fr> wrote:

> On Tue, 7 Oct 2014 17:42:56 +0000
> Mark Hedges <Ma...@Ticketmaster.com> wrote:
> >
> > 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.
> >
>
> How do you use that with a web application that is a work in progress,
> though?
>
> I write mod_perl modules that output html forms. One has to write a test
> that sends requests and compares the responses with an expected result. But
> that result changes every time I make the slightest change in code, which
> happens quite often and in multiple places. So maintaining the test suite
> on top of the code base seems appealing in theory, but I found it
> overwhelming in practice.
>
> I can see it happening for a well matured app that changes rarely, but for
> a new one?
>
>
> --
>                                         Regards, Vincent Veyron
>
> https://libremen.com/
> Legal case, contract and insurance claim management software
>



-- 
John Dunlap
*CTO | Lariat *

*Direct:*
*john@lariat.co <jo...@lariat.co>*

*Customer Service:*
877.268.6667
support@lariat.co

RE: beginning and testing

Posted by Mark Hedges <Ma...@Ticketmaster.com>.
-----Original Message-----
From: Vincent Veyron [mailto:vv.lists@wanadoo.fr] 
Sent: Tuesday, October 07, 2014 2:32 PM

On Tue, 7 Oct 2014 17:42:56 +0000
Mark Hedges <Ma...@Ticketmaster.com> wrote:
> 
> 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.  
> 

How do you use that with a web application that is a work in progress, though?

I write mod_perl modules that output html forms. One has to write a test that sends requests and compares the responses with an expected result. But that result changes every time I make the slightest change in code, which happens quite often and in multiple places. So maintaining the test suite on top of the code base seems appealing in theory, but I found it overwhelming in practice.

I can see it happening for a well matured app that changes rarely, but for a new one?

-------------------------------------

One of the main benefits of automated testing is that it helps in the development process as you write.  It sounds elitist, but if you haven't practiced it, you probably won't buy anyone's explanation that it is a good thing.

Regarding the other message from Jon about using frameworks, I would caution against that.  I wrote my own MVC handler framework Apache2::Controller on CPAN, but even that, I am sad to admit, is an abstraction in search of a problem.  See https://perl.apache.org/docs/2.0/user/coding/coding.html#Method_Handlers for how to create subclassable object-oriented handlers.

Mark

Re: beginning and testing

Posted by Vincent Veyron <vv...@wanadoo.fr>.
On Tue, 7 Oct 2014 17:42:56 +0000
Mark Hedges <Ma...@Ticketmaster.com> wrote:
> 
> 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.  
> 

How do you use that with a web application that is a work in progress, though?

I write mod_perl modules that output html forms. One has to write a test that sends requests and compares the responses with an expected result. But that result changes every time I make the slightest change in code, which happens quite often and in multiple places. So maintaining the test suite on top of the code base seems appealing in theory, but I found it overwhelming in practice.

I can see it happening for a well matured app that changes rarely, but for a new one?


-- 
					Regards, Vincent Veyron 

https://libremen.com/ 
Legal case, contract and insurance claim management software

Re: beginning and testing

Posted by Jon <th...@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 <Ma...@ticketmaster.com>
wrote:

>
>
> -----Original Message-----
> From: Patton, Billy [mailto:Billy.Patton@h3net.com]
> Sent: Tuesday, October 07, 2014 6:24 AM
> To: modperl@perl.apache.org
> 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
>

RE: beginning and testing

Posted by Mark Hedges <Ma...@Ticketmaster.com>.

-----Original Message-----
From: Patton, Billy [mailto:Billy.Patton@h3net.com] 
Sent: Tuesday, October 07, 2014 6:24 AM
To: modperl@perl.apache.org
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

Re: beginning and testing

Posted by Holger Kipp <Ho...@alogis.com>.
Dear Billy,

> On 07.10.2014, at 15:26, "Patton, Billy" <Bi...@h3net.com> wrote:
> 
> I’m rewriting/moving an app that hasn’t been touched in over 5 years.  [..]
> 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.

Have a look at Apache JMeter.

http://jmeter.apache.org

Maybe this is what you need?

Best regards,
Holger