[Catalyst] Detecting Incorrectly Displayed Page (Generating and Visiting URLS automatically ?)

Toby Corkindale tjc at wintrmute.net
Mon Feb 4 07:46:12 GMT 2008


On Mon, Feb 04, 2008 at 03:58:54PM +0900, sindharta_tanuwijaya at yahoo.co.jp wrote:
> Hi,
> 
> I am currently doing some tests with my application and I am wondering if there is any efficient and effective way to know if pages which should be displayed correctly are actually being redirected to another page, such as "404 - Data Not Found", because of some logic or data mismatches ?
> 
> One idea that came to my mind is by generating URLs and visiting generated URLs by our program, and check the used template file. For example, if we have 3 records, with '1','2','3' as their ids,  we want to do a loop to visit each generated URL and look if they are displayed correctly by
>  generating an output such as this:
> 
> URL                    ID   Used Template
> ---                     --   ------------
> localhost/key/1     1    index.tt2
> localhost/key/2     2.    error.tt2
> localhost/key/3     3.    index.tt2
> 
> But I am not sure if that is even possible. Any ideas ?

Well, you could edit every template file and put:
<!-- Template used: [% c.stash.template %] -->
.. but that seems, erm, Not Good.

Have you considered checking the status code of the pages in your tests?
eg.
for (1..3) {
    is( request("localhost/key/$_")->code, 200, 'Request succeeded' );
}




More information about the Catalyst mailing list