Forum Discussion
stebi
13 years agoOccasional Contributor
Ok, now I have a working code snippet. Also "Evaluate" needs the Unitname:
procedure Foo(Message: string);
begin
raise('Foo-Exception ' + Message);
end;
procedure Execute;
begin
try
Evaluate('Unit1.Foo(''From Evaluate'')'); // Exception inside Foo is successfully caught
except
Log.Message(ExceptionMessage);
end;
try
Runner.CallMethod('Unit1.Foo', 'From CallMethod');
except
Log.Message(ExceptionMessage); // Exception inside Foo is not caught. It turns in a "Script Runtime Error" an breaks the execution.
end;
end;
The expected behavior is that "Execute" runs successfully and posts two messages to log. But the second exception stops the execution.
Regarding the idea to avoid the exception: This is "impossible" because I architectured my tests around exceptions ;-) I write several conditions like I do in my applications unit tests:
CheckEquals(1, MyValue);
CheckFileExists(...)
Check(Condition);
etc.
The code should abort the current test when a condition is not met, but this should not stop other tests from starting. To respect a return value would make the tests unreadable.
Related Content
- 4 years ago
Recent Discussions
- 16 hours ago
- 23 hours ago
- 23 hours ago