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

sindharta_tanuwijaya at yahoo.co.jp sindharta_tanuwijaya at yahoo.co.jp
Mon Feb 4 08:21:52 GMT 2008


Wow, that white and black box testing  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.

Thank you very much for the links. I think Test::WWW::Mechanize is exactly what I need when I mentioned about template file tests.
 
Sindharta

Peter Edwards <peter at dragonstaff.com> wrote: >Sindharta wrote:
>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
h>ave 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

You are proposing testing based on which template is used. The error.tt2
template might be used for any number of reasons, some of them good as you
may do some failing tests that should fail.

I'd suggest a combination of testing at different levels, both 
"white box" http://en.wikipedia.org/wiki/White_box_testing
and "black box" http://en.wikipedia.org/wiki/Black_box_testing

you should have unit tests
http://en.wikipedia.org/wiki/Unit_testing

integration tests
http://en.wikipedia.org/wiki/Integration_testing

and regression tests
http://en.wikipedia.org/wiki/Regression_testing


you can achieve this by

1) Throw exceptions at different levels.
If your Model Model::Book (for example) fails to read book with record id 1,
throw an exception. If your controller logic detects an error, throw an
exception. Likewise inside your templates (if using Template::Toolkit) you
can throw an error if you detect inconsistent data.
http://search.cpan.org/search?query=catalyst%3A%3Aexception

2) Write web application tests that perform a logical sequence of login,
create records, follow links, test error conditions. Test::WWW::Mechanize
lets you check HTTP response status, e.g. 200 OK, 301/302 found redirect,
4xx error, and also the content of rendered page. So in your example, you
might look for string "record 1 not found" in the resulting HTML.

See

Catalyst::Manual::Tutorial::Testing
http://search.cpan.org/search?query=Catalyst%3A%3AManual%3A%3ATutorial%3A%3A
Testing&mode=all 

Test::WWW::Mechanize::Catalyst
http://search.cpan.org/search?query=Test%3A%3AWWW%3A%3AMechanize%3A%3ACataly
st&mode=all


Also

http://catwiki.toeat.com/fromtrac/testing.highlight 


Regards, Peter
http://perl.dragonstaff.co.uk



_______________________________________________
List: Catalyst at lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

 

 
---------------------------------
Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20080204/75b59164/attachment.htm


More information about the Catalyst mailing list