I've had some problems with FastMM false positives. This time, the leaks are in the cases testing forms. It's very similar to the one I described here.
I got a form and some plain old VCL controls in it. The first test run shows leaks which, in fact, doesn't exists. The second run gets no leaks. I've searched over all DUnit source code, but couldn't find the reason in order to fix it. Can somebody help me?
I can't afford to run the test twice because: 1. It will be run in a continuous integration; 2. Some tests really take some time and doubling it wouldn't be wise.
I checked the last 3 options in the DUnit GUI: - Report memory leak type on Shutdown - Fail TestCase if memory leaked - Ignore memory leak in SetUp/TearDown
Here are the sample codes:
// form
type
TForm2 = class(TForm)
button1: TButton;
end;
implementation
{$R *.dfm}
// test
type
TTest = class(TGUITestCase)
private
a: TForm2;
public
procedure SetUp; override;
procedure TearDown; override;
published
procedure Test;
end;
implementation
procedure TTest.Setup;
begin
a := TForm2.Create(nil);
end;
procedure TTest.TearDown;
begin
FreeAndNil(a);
end;
procedure TTest.Test;
begin
a.Show;
a.close;
end;