Wow, that white and black box testing&nbsp; reminds me a lot to what I learned when I took software engineering classes before, but I have to admit that I rarely (or never) pay attention to them when I perform my tests. Maybe it's time to start reviewing.<br>
<br>
Thank you very much for the links. I think Test::WWW::Mechanize is exactly what I need when I mentioned about template file tests.<br>
&nbsp;<br>
Sindharta<br>
<br>
<b>Peter Edwards &lt;peter@dragonstaff.com&gt;</b> wrote:<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> &gt;Sindharta wrote:<br>
&gt;I am currently doing some tests with my application and I am wondering if<br>
&gt;there is any efficient and effective way to know if pages which should be<br>
&gt;displayed correctly are actually being redirected to another page, such as<br>
&gt;"404 - Data Not Found", because of some logic or data mismatches ?<br>
&gt;<br>
&gt;One idea that came to my mind is by generating URLs and visiting generated<br>
&gt;URLs by our program, and check the used template file. For example, if we<br>
h&gt;ave 3 records, with '1','2','3' as their ids,  we want to do a loop to<br>
&gt;visit each generated URL and look if they are displayed correctly by<br>
&gt;generating an output such as this:<br>
&gt;<br>
&gt;URL                    ID   Used Template<br>
&gt;---                     --   ------------<br>
&gt;localhost/key/1     1    index.tt2<br>
&gt;localhost/key/2     2.    error.tt2<br>
&gt;localhost/key/3     3.    index.tt2<br>
<br>
You are proposing testing based on which template is used. The error.tt2<br>
template might be used for any number of reasons, some of them good as you<br>
may do some failing tests that should fail.<br>
<br>
I'd suggest a combination of testing at different levels, both <br>
"white box" http://en.wikipedia.org/wiki/White_box_testing<br>
and "black box" http://en.wikipedia.org/wiki/Black_box_testing<br>
<br>
you should have unit tests<br>
http://en.wikipedia.org/wiki/Unit_testing<br>
<br>
integration tests<br>
http://en.wikipedia.org/wiki/Integration_testing<br>
<br>
and regression tests<br>
http://en.wikipedia.org/wiki/Regression_testing<br>
<br>
<br>
you can achieve this by<br>
<br>
1) Throw exceptions at different levels.<br>
If your Model Model::Book (for example) fails to read book with record id 1,<br>
throw an exception. If your controller logic detects an error, throw an<br>
exception. Likewise inside your templates (if using Template::Toolkit) you<br>
can throw an error if you detect inconsistent data.<br>
http://search.cpan.org/search?query=catalyst%3A%3Aexception<br>
<br>
2) Write web application tests that perform a logical sequence of login,<br>
create records, follow links, test error conditions. Test::WWW::Mechanize<br>
lets you check HTTP response status, e.g. 200 OK, 301/302 found redirect,<br>
4xx error, and also the content of rendered page. So in your example, you<br>
might look for string "record 1 not found" in the resulting HTML.<br>
<br>
See<br>
<br>
Catalyst::Manual::Tutorial::Testing<br>
http://search.cpan.org/search?query=Catalyst%3A%3AManual%3A%3ATutorial%3A%3A<br>
Testing&amp;mode=all <br>
<br>
Test::WWW::Mechanize::Catalyst<br>
http://search.cpan.org/search?query=Test%3A%3AWWW%3A%3AMechanize%3A%3ACataly<br>
st&amp;mode=all<br>
<br>
<br>
Also<br>
<br>
http://catwiki.toeat.com/fromtrac/testing.highlight <br>
<br>
<br>
Regards, Peter<br>
http://perl.dragonstaff.co.uk<br>
<br>
<br>
<br>
_______________________________________________<br>
List: Catalyst@lists.scsys.co.uk<br>
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst<br>
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/<br>
Dev site: http://dev.catalyst.perl.org/<br>
</blockquote><br>

<div style="line-height: 0; width: 0; height: 5px; clear: both;">&nbsp;</div>
<p>&#32;

<hr size=1><a href=http://pr.mail.yahoo.co.jp/toolbar/ target="new">Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar</a><br>