View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Boris Sukholitko > HTML-Tested > HTML::Tested



Annotate this POD


New  2
Open  0
View/Report Bugs
Module Version: 0.58   Source  


HTML::Tested - Provides HTML widgets with the built-in means of testing.


    package MyPage;
    use base 'HTML::Tested';


    # Register my own widget
    __PACKAGE__->register_tested_widget('my_widget', 'My::App::Widget');

    # Later, in the test for example
    package main;

    my $p = MyPage->construct_somehow;
    my $stash = {};


    # stash contains x => 'Hi'
    # We can pass it to templating mechanism

    # Stash checking function
    my @errors = HTML::Tested::Test->check_stash(
            'MyPage', $stash, { x => 'Hi' });

    # Stash checking function
    my @errors = HTML::Tested::Test->check_text(
            'MyPage', '<html>x</html>', { x => 'Hi' });


This is pre-alpha quality software. Please use it on your own risk.


Imagine common web programming scenario - you have HTML page packed with checkboxes, edit boxes, labels etc.

You are probably using some kind of templating mechanism for this page already. However, your generating routine still has quite a lot of complex code.

Now, being an experienced XP programmer, you face the task of writing test code for the routine. Note, that your test code can deal with the results on two levels: we can check the stash that we are going to pass to the templating module or we can crawl our site and check the resulting text.

As you can imagine both of those scenarios require quite a lot of effort to get right.

HTML::Tested can help here. It does this by generating stash data from the widgets that you declare. Its testing code can check the existence of those widgets both in the stash and in the text of the page.


$class->ht_add_widget($widget_class, $widget_name, @widget_args)

Adds widget implemented by $widget_class to $class as $widget_name. @widget_args are passed as is into $widget_class->new function.

For example, A->ht_add_widget("HTML::Tested::Value", "a", default_value => "b"); will create value widget (and corresponding a accessor) in A class which will have default value "b".

See widget new function documentation for relevant @widget_args values (most of them are documented in HTML::Tested::Value class).


Renders all of the contained controls into the stash. stash should be hash reference.


Finds widget named $widget_name.

ht_bless_from_tree(class, tree)

Creates blessed instance of the class from tree.

ht_get_widget_option($widget_name, $option_name)

Gets option $option_name for widget named $widget_name.

ht_set_widget_option($widget_name, $option_name, $value)

Sets option $option_name to $value for widget named $widget_name.


Recursively validates all contained widgets. See HTML::Tested::Value for $widget-validate> method description.

Prepends the names of the widgets which failed validation into result arrays.

$root->ht_make_query_string($uri, @widget_names)

Makes query string from $uri and widget values.


Merges parameters with current values. Tries to reconstruct the state of the controls to user set values.

E.g. for EditBox it means setting its value to one in params. For checkbox - setting its checked state.


Documentation is too sparse to be taken seriously.


        Boris Sukholitko
        CPAN ID: BOSU


This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.


HTML::Tested::Test for writing tests using HTML::Tested. See HTML::Tested::Value::* for the documentation on the specific widgets. See HTML::Tested::List for documentation on list container.

syntax highlighting: