AL icon indicating copy to clipboard operation
AL copied to clipboard

Unable to create automated testing codeunits (handler functions not working)

Open AndriusAndrulevicius opened this issue 9 years ago • 3 comments

it looks like it's not possible to properly create test codeunits as handler functions aren't supported: [HandlerFunctions(MessageHandlerItem)] local procedure CreateItem(var Item2 : Record Item); begin Item2.Init; item2.Insert(true); Message('Item %1 created',item2."No."); end;
[MessageHandler] local procedure MessageHandlerItem(Msg : Text[1024]); begin
end; The code above generates error message: error AL0242: Invalid attribute argument syntax: 'MessageHandlerItem'

AndriusAndrulevicius avatar Aug 11 '17 06:08 AndriusAndrulevicius

The HandlerFunctions argument is a string literal. You need to single quote it.

We have a task on our backlog to change the textual reference to a symbolic reference, but for now it is just a string.

esbenk avatar Aug 11 '17 06:08 esbenk

thank you for the answer - that helps. But in that case maybe txt2al should convert it correctly? This code was generated by txt2al.

AndriusAndrulevicius avatar Aug 11 '17 06:08 AndriusAndrulevicius

It should;-) We will fix that.

esbenk avatar Aug 11 '17 07:08 esbenk