GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Jifty::Test(3) User Contributed Perl Documentation Jifty::Test(3)

Jifty::Test - Jifty's test module

    use Jifty::Test tests => 5;
    # to load po for test:
    # use Jifty::Test tests => 5, l10n => 1;

    # ...all of Test::More's functionality...
    my $model = MyApp::Model::MyModel->new;
    $model->create();
    ok($model->id, 'model works');
    is($model->foo, 'some default', 'default works');

    # Startup an external server (see Jifty::TestServer)
    my $server = Jifty::Test->make_server;
    my $server_url = $server->started_ok;
    # You're probably also interested in Jifty::Test::WWW::Mechanize

Jifty::Test is a superset of Test::More. It provides all of Test::More's functionality in addition to the class methods defined below.

    my $is_passing = Jifty::Test->is_passing;

Check if the test is currently in a passing state.

  • All tests run so far have passed
  • We have run at least one test
  • We have not run more than we planned (if we planned at all)

    my $is_done = Jifty::Test->is_done;

Check if we have run all the tests we've planned.

If the plan is 'no_plan' then is_done() will return true if at least one test has run.

This method is passed a single argument. This is a reference to the array of parameters passed in to the import statement.

Merges the "test_config" into the default configuration, resets the database, and resets the fake "outgoing mail" folder.

This is the method to override if you wish to do custom setup work, such as insert test data into your database.

  package MyApp::Test;
  use base qw/ Jifty::Test /;

  sub setup {
      my $self = shift;
      my $args = shift;

      # Make sure to call the super-class version
      $self->SUPER::setup($args);

      # Now that we have the database and such...
      my %test_args = @$args;

      if ($test_arg{something_special}) {
          # do something special...
      }
  }

And later in your tests, you may do the following:

  use MyApp::Test tests => 14, something_special => 1;

  # 14 tests with some special setup...

Create the test database. This can be overloaded if you do your databases in a different way.

This will load all the test config files that apply to FILENAME (default: $0, the current test script file). Say you are running the test script "/home/bob/MyApp/t/user/12-delete.t". The files that will be loaded are:
"/home/bob/MyApp/t/user/12-delete.t-config.yml"
"/home/bob/MyApp/t/user/test_config.yml"
"/home/bob/MyApp/t/test_config.yml"

..followed by the usual Jifty configuration files (such as "MyApp/etc/config.yml" and "MyApp/etc/site_config.yml"). The options in a more specific test file override the options in a less specific test file.

The options are returned in a single hashref.

Returns a hash which overrides parts of the application's configuration for testing. By default, this changes the database name by appending a 'test', as well as setting the port to a random port between 10000 and 15000. Individual test configurations may override these defaults (see "load_test_configs").

It is passed the current configuration before any test config is loaded.

You can override this to provide application-specific test configuration, e.g:

    sub test_config {
        my $class = shift;
        my ($config) = @_;
        my $hash = $class->SUPER::test_config($config);
        $hash->{framework}{LogConfig} = "etc/log-test.conf"
    
        return $hash;
    }

Note that this is deprecated in favor of having real config files in your test directory.

Creates a new Jifty::TestServer depending on the value of $ENV{JIFTY_TEST_SERVER}. If the environment variable is "Inline", we run tests using PSGI inline without spawning an actual server. Otherwise, we fork off a Plack::Server to run tests against.

Like calling "<Jifty-"web>>.

"<Jifty::Test-"web>> does the necessary Jifty->web initialization for it to be usable in a test.

A mailbox used for testing mail sending.

Clears the mailbox.

Deletes the mailbox.

Informs Email::Send that Jifty::Test is always available as a mailer.

Should not be called manually, but is automatically called by Email::Send when using Jifty::Test as a mailer.

(Note that it is a class method.)

Returns the messages in the test mailbox, as a list of Email::Simple objects. You may have to use a module like Email::MIME to parse multi-part messages stored in the mailbox.

  my $files = Jifty::Test->test_file($file);

Register $file as having been created by the test. It will be cleaned up at the end of the test run if and only if the test passes. Otherwise it will be left alone.

It returns $file so you can do this:

  my $file = Jifty::Test->test_file( Jifty::Util->absolute_path("t/foo") );

  my $return = Jifty::Test->test_in_isolation( sub {
      ...your testing code...
  });

For testing testing modules so you can run testing code (which perhaps fail) without effecting the outer test.

Saves the state of Jifty::Test's Test::Builder object and redirects all output to dev null before running your testing code. It then restores the Test::Builder object back to its original state.

    # Test that fail() returns 0
    ok !Jifty::Test->test_in_isolation sub {
        return fail;
    };

Jifty::Test::WWW::Mechanize, Jifty::TestServer
2015-04-30 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.