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=ffdbd316bab3d50435e327e4c00d15c13ee51690;hp=f3b2b6412e68a293ba60971f1dea7e2f5762d3ac;hb=d04961970a25ec3dc831f89be5cd6e27fdec884a;hpb=5e6026272f809951ac22fae43b73d2c1dc79c7fc diff --git a/lib/Catalyst/Manual/Tutorial/Testing.pod b/lib/Catalyst/Manual/Tutorial/Testing.pod index f3b2b64..ffdbd31 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 7: Testing +Catalyst::Manual::Tutorial::Testing - Catalyst Tutorial - Part 8: Testing =head1 OVERVIEW -This is B for the Catalyst tutorial. +This is B for the Catalyst tutorial. L @@ -21,34 +21,39 @@ L =item 3 -L +L =item 4 -L +L =item 5 -L +L =item 6 -L +L =item 7 -B +L =item 8 -L +B =item 9 +L + +=item 10 + L =back + =head1 DESCRIPTION You may have noticed that the Catalyst Helper scripts automatically @@ -71,9 +76,20 @@ directory, enter: $ prove --lib lib t -The redirection used by the Authentication plugins will cause the -default C to fail. You can fix this by changing the line in -C that read: +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. + # Looks like you failed 1 test of 3. + +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: ok( request('/')->is_success, 'Request should succeed' ); @@ -81,13 +97,11 @@ to: ok( request('/login')->is_success, 'Request should succeed' ); -So that a redirect is not necessary. Also, the C -and C default test cases will fail because of the -authorization. You can delete these two files to prevent false error -messages: +2) Change the Cis_success> to +Cis_redirect> in C. - $ rm t/controller_Books.t - $ rm t/controller_Logout.t +3) Change the Cis_success> to +Cis_redirect> in 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 @@ -115,6 +129,7 @@ prints the name of each test case as it is being run: $ CATALYST_DEBUG=0 TEST_POD=1 prove --lib lib -v t + =head1 RUNNING A SINGLE TEST You can also run a single script by appending its name to the C @@ -122,11 +137,12 @@ command. For example: $ CATALYST_DEBUG=0 prove --lib lib t/01app.t -Note that you can also run tests directly from Perl without C. +Also note that you can also run tests directly from Perl without C. For example: $ CATALYST_DEBUG=0 perl -Ilib t/01app.t + =head1 ADDING YOUR OWN TEST SCRIPT Although the Catalyst helper scripts provide a basic level of checks @@ -312,18 +328,14 @@ L is that it runs your full application; however, this can complicate things when you want to support multiple databases. One solution is to allow the database specification to be overridden with an environment variable. -For example, open C in your editor and +For example, open C in your editor and change the C<__PACKAGE__-Econfig(...> declaration to resemble: my $dsn = $ENV{MYAPP_DSN} ||= 'dbi:SQLite:myapp.db'; __PACKAGE__->config( - schema_class => 'MyAppDB', + schema_class => 'MyApp::Schema', connect_info => [ $dsn, - '', - '', - { AutoCommit => 1 }, - ], ); @@ -344,7 +356,7 @@ Kennedy Clark, C Please report any errors, issues or suggestions to the author. The most recent version of the Catalyst Tutorial can be found at -L. +L. Copyright 2006, Kennedy Clark, under Creative Commons License (L).