VSoftTechnologies/DUnitX

SetUp/TearDown exactly once for all test methods in a TestCase ?

alan008 opened this issue · 3 comments

I'm migrating from DUnit to DUnitX. Everything seems fine, but I'm lacking one piece of functionality.
In DUnit there was a way to execute SetUp/TearDown not for every Test method in TestCase, but once for the whole TestCase (once for all methods inside TestCase).
This was made but TTestSetup class, in which SetUp and TearDown were overriden, and registration of the test case was special:
not just
RegisterTest(TSomeTestCase.Suite)
but
RegisterTest(TSomeTestSetup.Create(TSomeTestCase.Suite))
SetUp and TearDown were in TSomeTestSetup class and they were called one time for all Test methods inside TSomeTestCase.

Is there something similar in DUnitX? My SetUp method is slow (it connects to some server), so its not convinient to reconnect for every test method execute. I want to connect once and then execute all test methods (100+ of them) and then disconnect.

SetupFixture and TeardownFixture attributes are what you are looking for,

Not sure, what am I doing wrong. I've created empty example in Delphi 11 Alexandria (with built-in version of DUnitX) , wrote [Setup], [TearDown], [SetupFixture], [TeardownFixture] attributes, but these methods are not called

DUnit_Test.zip
2022-01-27_14-14-45

Ahh, must be PUBLIC methods. The more you live the more you know...