in reply to Sharing configuration information among test files

but that would mean each file would have to open and read the configuration file.

why is that a problem?

  • Comment on Re: Sharing configuration information among test files

Replies are listed 'Best First'.
Re^2: Sharing configuration information among test files
by talexb (Chancellor) on Aug 15, 2008 at 15:18 UTC

    It's something I'd like to avoid, just because it's duplication. If there's a workaround, great. If I have to open and read a config file each time for each set of tests, then that's that.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

      You can put the duplicated code in a module (as you would in non-test code). Then your test scripts can look like:
      use Test::More; use MyApp::Frob; use MyApp::Test::Config; my $cfg = MyApp::Test::Config->cfg; my $frob = MyApp::Frob->new($cfg->whoToFrob, $cfg->whatToFrob); ok($frob, "can create a frob");