RT 5.0.7 Documentation



RT::Test - RT Testing



To run the RT test suite with coverage support, install Devel::Cover and run:

    cover -ignore_re '^var/mason_data/' -ignore_re '^t/'

The coverage tests have DevelMode turned off, and have named_component_subs enabled for HTML::Mason to avoid an optimizer problem in Perl that hides the top-level optree from Devel::Cover.





switch_templates_to TYPE

This runs /opt/rt5/etc/upgrade/switch-templates-to in order to change the templates from HTML to text or vice versa. TYPE is the type to switch to, either html or text.

switch_templates_ok TYPE

Calls switch_template_to and tests the return values.


Takes an RT::Scrip object or ID as the first argument and an arrayref of RT::Queue objects and/or Queue IDs as the second argument.

The scrip's applications (RT::ObjectScrip records) are tested to ensure they exactly match the arrayref.

An optional third arrayref may be passed to enumerate and test the queues the scrip is not added to. This is most useful for testing the API returns the correct results.


Takes a path relative to the location of the test file that is being run and returns a path that takes the invocation path into account.

e.g. RT::Test::get_relocatable_dir(File::Spec-updir(), 'data', 'emails')>

Parent directory traversals (.. or File::Spec->updir()) are naively canonicalized based on the test file path ($0) so that symlinks aren't followed. This is the exact opposite behaviour of most filesystems and is considered "wrong", however it is necessary for some subsets of tests which are symlinked into the testing tree.


Same as get_relocatable_dir, but takes a file and a path instead of just a path.

e.g. RT::Test::get_relocatable_file('test-email', (File::Spec->updir(), 'data', 'emails'))


Starts the test web server, referencing $ENV{'RT_TEST_WEB_HANDLER'} to determine which web server to use. Defaults to an inline server running with Plack.

Returns the base URL of the started server, including the port. Also returns a Mechanize object useful for additional tests.

    my ( $baseurl, $m ) = RT::Test->started_ok();
    diag "Test server running at: $baseurl";
    ok( $m->login, 'Log in' );

If your tests change configuration stored in the DB as part of the test, you can disable the DB config cache:

    my ( $baseurl, $m ) = RT::Test->started_ok( disable_config_cache => 1 );

Without this, you may find tests intermittently failing because the config update code needs 1 second to recognize an update is needed.

← Back to index