X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FTesting.pod;h=eb67ebb58dc755e201f03ef10bb93c13932a2c11;hp=2b771b3f79a0b2f6607e25d3b086f1d10cdb0812;hb=a46b474eb241c3eac09ac0cd8af400a864de3ee5;hpb=6a72d1bf08361c568bb6bd4c86d42016227c9681 diff --git a/lib/Catalyst/Manual/Tutorial/Testing.pod b/lib/Catalyst/Manual/Tutorial/Testing.pod index 2b771b3..eb67ebb 100644 --- a/lib/Catalyst/Manual/Tutorial/Testing.pod +++ b/lib/Catalyst/Manual/Tutorial/Testing.pod @@ -1,11 +1,11 @@ =head1 NAME -Catalyst::Manual::Tutorial::Testing - Catalyst Tutorial - Part 8: Testing +Catalyst::Manual::Tutorial::Testing - Catalyst Tutorial - Chapter 8: Testing =head1 OVERVIEW -This is B for the Catalyst tutorial. +This is B for the Catalyst tutorial. L @@ -56,15 +56,15 @@ L =head1 DESCRIPTION -You may have noticed that the Catalyst Helper scripts automatically -create basic C<.t> test scripts under the C directory. This part of -the tutorial briefly looks at how these tests can be used to not only -ensure that your application is working correctly at the present time, -but also provide automated regression testing as you upgrade various -pieces of your application over time. +You may have noticed that the Catalyst Helper scripts automatically +create basic C<.t> test scripts under the C directory. This +chapter of the tutorial briefly looks at how these tests can be used +to not only ensure that your application is working correctly at the +present time, but also provide automated regression testing as you +upgrade various pieces of your application over time. -You can checkout the source code for this example from the catalyst -subversion repository as per the instructions in +You can check out the source code for this example from the Catalyst +Subversion repository as per the instructions in L. @@ -77,10 +77,10 @@ directory, enter: $ prove --lib lib t -There will be a lot of output because we have the C<-Debug> flag enabled -in C (see the C tip below for a quick -and easy way to reduce the clutter). Look for lines like this for -errors: +There will be a lot of output because we have the C<-Debug> flag +enabled in C (see the C tip below for +a quick and easy way to reduce the clutter). Look for lines like this +for errors: # Failed test 'Request should succeed' # in t/controller_Books.t at line 8. @@ -90,7 +90,7 @@ The redirection used by the Authentication plugins will cause several failures in the default tests. You can fix this by making the following changes: -1) Change the line in C that read: +1) Change the line in C that reads: ok( request('/')->is_success, 'Request should succeed' ); @@ -98,13 +98,13 @@ to: ok( request('/login')->is_success, 'Request should succeed' ); -2) Change the Cis_success> to -Cis_redirect> in C. +2) Change the "Cis_success>" to +"Cis_redirect>" in C. -3) Change the Cis_success> to -Cis_redirect> in C. +3) Change the "Cis_success>" to +"Cis_redirect>" in C. -4) Add C to the top of C. +4) Add "C" to the top of C. As you can see in the C command line above, the C<--lib> option is used to set the location of the Catalyst C directory. With this @@ -116,6 +116,29 @@ environment variable. For example: $ CATALYST_DEBUG=0 prove --lib lib t +B Depending on the versions of various modules you have +installed, you might get some C warnings -- you can +ignore these. If you want to elliminate the warnings, you can +edit C to disable and then re-enable warnings +are the C line in C. +You can locate where C is located with the +following command (it's probably in a place similar to +C): + + perldoc -l Template::Base + +Edit the file and modify C to match: + + ... + { no strict qw( refs ); + # Disable warnings + no warnings; + $argnames = \@{"$class\::BASEARGS"} || [ ]; + # Turn warnings back on + use warnings; + } + ... + During the C and C tests, you might notice the C warning message. To execute the Pod-related tests, add C to the C @@ -212,7 +235,7 @@ editor and enter the following: "Check we ARE logged in" ) for $ua1, $ua2; # 'Click' the 'Logout' link (see also 'text_regex' and 'url_regex' options) - $_->follow_link_ok({n => 1}, "Logout via first link on page") for $ua1, $ua2; + $_->follow_link_ok({n => 4}, "Logout via first link on page") for $ua1, $ua2; $_->title_is("Login", "Check for login title") for $ua1, $ua2; $_->content_contains("You need to log in to use this application", "Check we are NOT logged in") for $ua1, $ua2; @@ -229,7 +252,7 @@ editor and enter the following: $_->content_contains("Book List", "Check for book list title") for $ua1, $ua2; # Make sure the appropriate logout buttons are displayed - $_->content_contains("/logout\">Logout", + $_->content_contains("/logout\">User Logout", "Both users should have a 'User Logout'") for $ua1, $ua2; $ua1->content_contains("/books/form_create\">Create", "Only 'test01' should have a create link"); @@ -289,10 +312,10 @@ or $ DBIC_TRACE=0 CATALYST_DEBUG=0 prove --lib lib -v t/live_app01.t -Experiment with the C, C -and C<-v> settings. If you find that there are errors, use the -techniques discussed in the "Catalyst Debugging" section (Part 7) to -isolate and fix any problems. +Experiment with the C, C and C<-v> +settings. If you find that there are errors, use the techniques +discussed in the "Catalyst Debugging" section (Chapter 7) to isolate +and fix any problems. If you want to run the test case under the Perl interactive debugger, try a command such as: @@ -321,6 +344,12 @@ failed test: This will cause the full HTML returned by the request to be displayed. +Another approach to see the full HTML content at the failure point in +a series of tests would be to insert a "C<$DB::single=1;> right above +the location of the failure and run the test under the perl debugger +(with C<-d>) as shown above. Then you can use the debugger to explore +the state of the application right before or after the failure. + =head1 SUPPORTING BOTH PRODUCTION AND TEST DATABASES