Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Greetings wise brothers.

I am looking to develop a simple mod_perl application that will eventually run under Apache2, however I would like to develop the logic and flow of my application first without the complexity of running it inside Apache. I would also like to use the perl debugger to step from the test script into my mod_perl application.

I was hoping to develop the application via test driven development, so I could write something like:

use strict; use warnings; use Test::Most tests => 4; use Test::Apache::ModPerl::Test::Harness; # No such module use_ok('MyServer'); my $testHarness = Test::Apache::ModPerl::Test::Harness->new(); my $result = $testHarness->request('/hello/world'); is($result->response, 200, 'Response was success'); is($result->headers->{'some-header'}, 'magic', 'Magic header returned' +); is($result->body, 'Hello world', 'Expected body returned'); done_testing(4);

Unfortunately, I can't find a test harness that will allow me to test as I have described above. This surprises me as I have done similar testing in the past with Catalyst::Test and it has worked very nicely.

I first investigated Apache2::FakeRequest, and found that while it can create working mock requests, the response body does not get captured, but goes to stdout. The headers appear to go missing entirely.

I also investigated Test::Apache2. Version 2.05 would not build on my Linux box (Ubuntu Oneiric, x86_64), Version 2.04 did build and install, but then broke when my test application called $r->content_type('text/plain'), which is straight from the mod_perl fast start documentation.

I took a look at Apache::Test, but it looks complex to setup, and it is not clear if it is possible to use the perl debugger in any useful way. I also considered not using and mod_perl specific test harness and just using LWP in my test script, and point it to the real web server, but again there would be no way to use the perl debugger.

Am I missing something, or is there realy no simple way to test a mod_perl application?


In reply to Apache mod_perl: Test driven developent? by chrestomanci

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2022-12-09 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?