j416
14 years agoOccasional Contributor
DUnit test + try/finally
Hi,
I'm trying to get my TestedApp, which is a DUnit GUI, to terminate after a completed run. It works well if all DUnit tests pass, but if any of them fails, it seems the finally clause (see below) is not reached and the application remains running.
How can I solve this?
procedure CloseApp;
var global: OleVariant;
begin
global := TestedApps.Global;
if not global.Close then begin
global.Terminate;
end;
global := Sys.WaitProcess('Global', 0);
if global.Exists then begin
global.Close;
end;
end;
procedure DUnitTestRunner;
begin
CloseApp;
try
TestedApps.Global.Run;
DUnitTests.DUnitTest.Execute;
finally
CloseApp;
end;
end;
Thank you,
Johan
I'm trying to get my TestedApp, which is a DUnit GUI, to terminate after a completed run. It works well if all DUnit tests pass, but if any of them fails, it seems the finally clause (see below) is not reached and the application remains running.
How can I solve this?
procedure CloseApp;
var global: OleVariant;
begin
global := TestedApps.Global;
if not global.Close then begin
global.Terminate;
end;
global := Sys.WaitProcess('Global', 0);
if global.Exists then begin
global.Close;
end;
end;
procedure DUnitTestRunner;
begin
CloseApp;
try
TestedApps.Global.Run;
DUnitTests.DUnitTest.Execute;
finally
CloseApp;
end;
end;
Thank you,
Johan