I guess the best practice in unit testing is writing code always called (like create object , do a primary init of these objects, .... ) for a test inside the setup procedure
[TestFixture]
TMY_Testcases = class
private
FTestConfigParameter: TParameter;
public
[Setup]
procedure Setup;
[TearDown]
procedure TearDown;
[Test]
[TestCase('CreateTrue', 'True')]
[TestCase('CreateFalse', 'False')]
procedure Test_DoMyTest (Createflag : Boolean);
end;
I have several sets of parameters for my objects I do the object.create in the setup procedure. Is there any way to run the test cases with the setup procedure getting my parameter? My ugl solution goes like this :
[Setup]
procedure Setup;
[TearDown]
procedure TearDown;
procedure MySetup(MyParameter : TParameter);
[TestCase('CreateWithParameter', 'False,Parameter_AsString')]
procedure Test_DoMyTest (Createflag : Boolean, Parameter : TParameter);
This approach makes setup and Teardown procedure obsolete, any better approach?