Kateryna
11 years agoContributor
Rerun keyword test in OnLogError script
Hello,
How can I rerun current test, if I receive a specific error in log?
I created event handler on Log error and it has following code, but it doesn't work:
How can I rerun current test, if I receive a specific error in log?
I created event handler on Log error and it has following code, but it doesn't work:
procedure
GeneralEvents_OnLogError(Sender; LogParams);
var
TestItems2: OleVariant;
begin
if
LogParams.MessageText = 'Unable to terminate' then
begin
TestItems2:= Project.TestItems.Current.Name;
KeywordTests.TestItems2.Run();
end;
end;
- Hi Kateryna,
I believe that the correct syntax is (untested):
TestItems2:= Project.TestItems.Current.Name;
evaluate('KeywordTests.' + TestItems2 + '.Run()');
However, considering that the test will be started from within the error handler, I am not sure that this is the best approach as it may cause recurrent execution of the same test and exaust memory resources on the test computer.
As a side note: you should also check that TestItems.Current is not nil, which is true if a standalone test/keyword test was executed.