I'm starting with DUnit tests so sorry in advance for any newbie mistakes. When I tried to run simple tests and the compiler runs the SetUp of my test class, it stops returning the message 'Cannot create form. No MDI forms are currently active'.
After some research, I found some explanations but none related to my problem.
The problem appears to be when I call the Create method of my child origin class - by origin I mean the class where I have all the procedures and functions to be tested, lets call it by TfrmFoo. And my test class should be the TestTfrmFoo. The TFrmFoo has a parent with some basic codes, the TfrmParentFoo.
I'm calling the Create method like this:
...
implementation
procedure TestTfrmFoo.SetUp;
begin
FfrmParentFoo := TfrmParentFoo.Create(nil);
FfrmFoo := TfrmFoo.Create(FfrmParentFoo);
end;
procedure TestTfrmFoo.TearDown;
begin
FfrmFoo.Free;
FfrmFoo := nil;
end;
...
After that, the Create method of the TfrmFoo class is called and the following error occurs: 'Cannot create form. No MDI forms are currently active'.
I already tried to override the Create of my child class TfrmFoo setting the FormStyle property to 'fsNormal' instead 'fsMDIChild' and nothing. I also found some ideas about using a sleep(500) but the problem continues.
Edited:
After the Remy Lebeau
contribution, I changed the SetUp test to create the parent form before calling the child, and using it as a parameter to the Create child. Same error message. Did I change something wrong?
Any other tips? tks!