5

I have a bunch of tests for my DBIx::Class schema and I am using Test::DBIx::Class. This is great as it gives me useful test functions and loads fixtures. It also has a Test::mysqld trait so I can dynamically create a test mysqld instance, deploy the schema, load fixtures and test. But if I have a bunch of test scripts it seems silly to start the server, deploy and load fixtures at the start of each script when instantiating via the constructor.

What is the best way to create the test database and populate it for the duration of my tests?

cjm
  • 61,471
  • 9
  • 126
  • 175
cubabit
  • 2,527
  • 3
  • 21
  • 34
  • 1
    I have had further thoughts about this and come to the conclusion that I should split my fixtures up and only load the ones that are used by that test script. Makes sense so then the test scripts can be run independently or with prove's --shuffle without things blowing up! – cubabit Jan 21 '11 at 17:20
  • http://blogs.perl.org/users/ovid/2014/02/easy-fixtures-with-dbix-class.html – Eugen Konkov Jul 19 '18 at 10:38

2 Answers2

1

At work one of the first tests we run loads all the fixtures the rest of the tests require. That's one way of managing it but your later comment also sounds sensible.

Adam Taylor
  • 7,534
  • 8
  • 44
  • 54
1

I have had further thoughts about this and come to the conclusion that I should split my fixtures up and only load the ones that are used by that test script. Makes sense so then the test scripts can be run independently or with prove's --shuffle without things blowing up!

cubabit
  • 2,527
  • 3
  • 21
  • 34