Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DUnit: 'Global' SetUp and TearDown

In DUnit, SetUp and TearDown are called before (and after, respectively) each test method is executed.
In SetUp, I create an object that loads data from a file. This is slow, especially if I have many tests.
Is there any way to call SetUp once, before executing ALL tests (and obviously the same for TearDown)?

like image 523
Server Overflow Avatar asked Oct 02 '14 17:10

Server Overflow


1 Answers

From the documentation:

TTestSetup

TTestSetup can be used when you wish to set up state exactly once for a test case class (the SetUp and TearDown methods are called once for each test method). For example, if you were writing a suite of tests to exercise some database code, you might subclass TTestSetup and use it to open and close the database before executing the suite.

An an example how to use TTestSetup

like image 53
whosrdaddy Avatar answered Oct 11 '22 15:10

whosrdaddy