FAQ
I'm trying to set up application testing the with module described in
the subject.

However, when my application is loaded in the testscript with:

use_ok ('Test::WWW::Mechanize::Catalyst', 'CalApp');
my $u = Test::WWW::Mechanize::Catalyst->new;

most of the things I've setup to be done on loading in my CalApp doesn't
seem to be done. So the plugins doesn't seem to be loaded and similar.

I haven't done any deep testing, but a simple:

print Dumper (__PACKAGE__->config);

in my CalApp.pm shows the normal configuration when I start the CalApp
application normally, but it doesn't even seem to be run when I start it
through the test script.

Naturally, when invoking my CalApp through the testscript it starts
complaining about missing configuration (connect_info etc.).

I must be missing something really basic here. Any clues?

Thanks,

Marius K.

Search Discussions

  • Ivorw at Jul 31, 2008 at 2:11 pm

    Marius Kjeldahl wrote:
    I'm trying to set up application testing the with module described in
    the subject.

    However, when my application is loaded in the testscript with:

    use_ok ('Test::WWW::Mechanize::Catalyst', 'CalApp');
    my $u = Test::WWW::Mechanize::Catalyst->new;
    Have you tried the next step, which is usually

    $u->get_ok( 'http://localhost/', 'Request should succeed' );


    Secondly, have you tried running with catalyst debug turned on? You
    might want to run your test with CATALYST_DEBUG=1 in order to see what
    is happening.
  • Marius Kjeldahl at Jul 31, 2008 at 2:23 pm

    ivorw wrote:
    Have you tried the next step, which is usually

    $u->get_ok( 'http://localhost/', 'Request should succeed' );
    Yes,

    my $APPLOC = 'http://localhost/calapp/no';
    $u->get_ok ($APPLOC, 'Application startup');

    fails with:

    Couldn't instantiate component "CalApp::Model::CalAppDB", "Either
    ->config->{connect_info} must be defined for CalApp::Model::CalAppDB or
    CalAppDB must have connect info defined on itHere's what we got:
    $VAR1 = bless( {
    'schema_class' => 'CalAppDB',
    'connect_info' => undef
    }, 'CalApp::Model::CalAppDB' );
    at /usr/local/share/perl/5.8.8/Catalyst/Test.pm line 90" at
    /usr/local/share/perl/5.8.8/Catalyst/Test.pm line 90

    Basically, it's complaining about missing connect_info. When I use
    CalApp "normally" (running script/calapp_server.pl) everything,
    including config with connect_info, is set up like it should.

    For some reason, when CalApp is started through the test module the
    CalApp module doesn't seem to initialize correctly.
    Secondly, have you tried running with catalyst debug turned on? You
    might want to run your test with CATALYST_DEBUG=1 in order to see what
    is happening.
    It's already running with full debug information. Lots of debug when run
    "normally", nothing when started with the script. Looks like I'm missing
    something vital that will/should kick off the CalApp server "properly",
    but I thought Test::WWW::Mechanize::Catalyst would take care of that
    when I told it to load 'CalApp' in the use statement.

    Thanks,

    Marius K.
  • Ivorw at Jul 31, 2008 at 6:11 pm

    Marius Kjeldahl wrote:
    my $APPLOC = 'http://localhost/calapp/no';
    $u->get_ok ($APPLOC, 'Application startup');

    fails with:

    Couldn't instantiate component "CalApp::Model::CalAppDB", "Either
    ->config->{connect_info} must be defined for CalApp::Model::CalAppDB
    or CalAppDB must have connect info defined on itHere's what we got:
    $VAR1 = bless( {
    'schema_class' => 'CalAppDB',
    'connect_info' => undef
    }, 'CalApp::Model::CalAppDB' );
    at /usr/local/share/perl/5.8.8/Catalyst/Test.pm line 90" at
    /usr/local/share/perl/5.8.8/Catalyst/Test.pm line 90
    I've seen this or similar. It's usually an indication that the Catalyst
    code is failing to see the config file (calappdb.yml or calappdb.conf),
    when you are defining the DBI parameters here rather than hardcoding
    them inside CalApp::Model::CalAppDB.pm which the helper script does for
    you by default.

    Maybe you're running your tests from a different directory than where
    the config file lives. Try running your test with CALAPP_CONFIG=/path/to/dir

    I actually have a special config I use for running tests (though the
    default tests that get created are completely safe to run against the
    live database). My tests are destructive, and start by creating a brand
    new SQLite database that I can run against.
  • Ivorw at Jul 31, 2008 at 6:36 pm
    Oops! Typo alert!

    The config file of course wouldn't have db in the name, but would be
    calapp.conf or calapp.yml

    ivorw wrote:
    Marius Kjeldahl wrote:
    my $APPLOC = 'http://localhost/calapp/no';
    $u->get_ok ($APPLOC, 'Application startup');

    fails with:

    Couldn't instantiate component "CalApp::Model::CalAppDB", "Either
    ->config->{connect_info} must be defined for CalApp::Model::CalAppDB
    or CalAppDB must have connect info defined on itHere's what we got:
    $VAR1 = bless( {
    'schema_class' => 'CalAppDB',
    'connect_info' => undef
    }, 'CalApp::Model::CalAppDB' );
    at /usr/local/share/perl/5.8.8/Catalyst/Test.pm line 90" at
    /usr/local/share/perl/5.8.8/Catalyst/Test.pm line 90
    I've seen this or similar. It's usually an indication that the Catalyst
    code is failing to see the config file (calappdb.yml or calappdb.conf),
    when you are defining the DBI parameters here rather than hardcoding
    them inside CalApp::Model::CalAppDB.pm which the helper script does for
    you by default.

    Maybe you're running your tests from a different directory than where
    the config file lives. Try running your test with CALAPP_CONFIG=/path/to/dir

    I actually have a special config I use for running tests (though the
    default tests that get created are completely safe to run against the
    live database). My tests are destructive, and start by creating a brand
    new SQLite database that I can run against.


    _______________________________________________
    List: Catalyst@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/
  • Marius Kjeldahl at Jul 31, 2008 at 7:30 pm

    ivorw wrote:
    I've seen this or similar. It's usually an indication that the Catalyst
    code is failing to see the config file (calappdb.yml or calappdb.conf),
    when you are defining the DBI parameters here rather than hardcoding
    them inside CalApp::Model::CalAppDB.pm which the helper script does for
    you by default.

    Maybe you're running your tests from a different directory than where
    the config file lives. Try running your test with CALAPP_CONFIG=/path/to/dir
    Thanks for the tip. I am running from the same directory, so am
    surprised that the behavior is different, but when setting the
    CALAPP_CONFIG variable as you suggested I see a normal Catalyst startup,
    and the "Dumper" code I put in gets ran as expected. Things look more
    normal now (well, there's other stuff it doesn't find now, like not
    recognizing the directories set in my default View, but I believe I can
    figure that out).

    Thanks again for helping out.

    Marius K.
  • Marius Kjeldahl at Aug 1, 2008 at 12:28 pm
    Just a final followup; removing some hardcoded "use lib ..." paths in
    the test framework made everything behave identical on all installed
    systems. The problem was that one of the systems actually had some older
    stuff in one of the hardcoded paths that got picked up that made it bomb
    out on that system.

    Thanks,

    Marius K.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedJul 31, '08 at 1:51p
activeAug 1, '08 at 12:28p
posts7
users2
websitecatalystframework.org
irc#catalyst

2 users in discussion

Marius Kjeldahl: 4 posts Ivorw: 3 posts

People

Translate

site design / logo © 2021 Grokbase