Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Setting up a test db with MakeMaker

by choroba (Chancellor)
on Feb 23, 2013 at 09:46 UTC ( #1020293=note: print w/replies, xml ) Need Help??


in reply to Setting up a test db with MakeMaker

If you need a code to be called from each .t file, what about wrapping it into a module? You can even place it into the t/ directory and just add the following to each .t file:
use TestSetup;
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Setting up a test db with MakeMaker
by danmcb (Monk) on Feb 25, 2013 at 14:10 UTC

    indeed, this works fine. Some code for those that are curious:

    in t/test_setup.pm:

    package test_setup; sub setup { # setup your db or whatever here } 1;

    In a test module

    require t::test_setup; test_setup::setup();

    Rather simple in fact. Works fine on 5.10

    UPDATE: in fact - I am using this.

    package test_setup; sub setup { # ... } BEGIN { # must be after the sub definition setup(); $ENV{USE_TEST_DB} = 1; } 1;

    And in my Catalyst MyApp.pm class:

    if ( $ENV{USE_TEST_DB} ) { __PACKAGE__->config( 'Plugin::ConfigLoader' => { file => 'myapp_test +.yml'} ); }

    Now it is only necessary to "use" test_setup.pm. The setup is executed automatically, and the ENV variable causes the Catalyst app to use another config, which in turn connects to the test database in place of the normal development one.

Re^2: Setting up a test db with MakeMaker
by tmharish (Friar) on Feb 23, 2013 at 10:08 UTC
    what about wrapping it into a module? You can even place it into the t/ directory and just add the following to each .t file: use TestSetup;

    Does that work on 5.6?

      Does that work on 5.6?

      Why should it not work? Why don't you try it?

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
        Why should it not work?

        Because I assumed that this will require BUILD_REQUIRES to be set and the default ExtUtils::MakeMaker version that shipped with 5.6 dint have it.

        Why don't you try it?

        I did and am yet to get it to work ( even on higher versions ) - Will reply once I find a way to get it to work or I give up, meanwhile - Did you?

        Update: I Managed it with a require 't/tests.pm'. I am not sure that thats what choroba meant though.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020293]
help
Chatterbox?
[Mj1234]: Hello Monks, I have installed Active perl 5.16 and 5.14 but I dont find Devel::GDB package when I try to install through ppm
[Discipulus]: i'v installed ubuntu 16.04lts and i'm quite disappointed: is deadly simmilar to new win osses where you cannot find even simple things...
[Corion]: Hi Discipulus ;)
[Corion]: Mj1234: Maybe Ubuntu didn't package Devel::GDB? In that case, consider using local::lib and install the module from CPAN
[Corion]: But a quick Google search turns up this page, which seems to suggest that it should be packaged
[Discipulus]: iirc active perl has repositories only for last 2 o 3 major release of perl Mj1234. I strongly suggest portable version of strawberry perl and use cpan client to install modules
[choroba]: Also, who needs GDB when there's hdb?

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2016-12-07 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (125 votes). Check out past polls.