DUnit: "Global" SetUp and TearDown

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

+5
source share
1 answer

From the documentation :

TTestSetup

TTestSetup can be used if you want to configure the state exactly once for the test case class (the SetUp and TearDown methods are called once for each test method). For example, if you are writing a test suite to execute some database code, you can subclass TTestSetup and use it to open and close the database before executing the package.

TTestSetup example

+10
source

Source: https://habr.com/ru/post/1203886/


All Articles