Message Handler in Page Testing
ta5
Member Posts: 1,164
Hi
I’m doing some tests with page testing. Nice feature, but there is a lot to consider
For the moment I have two questions. First have a look at the scenario :
Explanations to the above code:
- Codeunit is defined as a testing codeunit
- The OnRun trigger calls test function "code"
- Function „code“, property "HandlerFunctions" has the value of the 2 functions "FirstMsgHandler" and "SecondMsgHandler"
So now the questions:
Question 1:
Test fails, because FirstMsgHandler throws an error because of wrong text. How to fix? Can one test function properly handle more than 1 message? Or should the MessageHandler handle more than 1 text?
Question 2:
If in function code „MESSAGE('A second message')" is deactivated, I get an error which says „The following UI handlers were not executed: SecondMsgHandler“. Obviously I don’t understand how and when the message handlers are triggered and how the messages are tied to a specific handler if more than one handler is present..... Maybe some of you knows more about it.
Thx in advance
Thomas
I’m doing some tests with page testing. Nice feature, but there is a lot to consider
For the moment I have two questions. First have a look at the scenario :
OnRun()
Code;
[Test] Code()
// Opens a blank customer card test page.
Customerpage.OPENNEW;
Customerpage."No.".SETVALUE('1234');
MESSAGE('A first message');
MESSAGE('A second message');
Customerpage.CLOSE;
[MessageHandler] FirstMsgHandler(_Msg : Text[1024])
IF _Msg <> 'A first message' THEN BEGIN
ERROR('Unexpected msg in FirstMsgHandler');
END;
[MessageHandler] SecondMsgHandler(_Msg : Text[1024])
IF _Msg <> 'A second message' THEN BEGIN
ERROR('Unexpected msg in SecondMsgHandler');
END;
Explanations to the above code:
- Codeunit is defined as a testing codeunit
- The OnRun trigger calls test function "code"
- Function „code“, property "HandlerFunctions" has the value of the 2 functions "FirstMsgHandler" and "SecondMsgHandler"
So now the questions:
Question 1:
Test fails, because FirstMsgHandler throws an error because of wrong text. How to fix? Can one test function properly handle more than 1 message? Or should the MessageHandler handle more than 1 text?
Question 2:
If in function code „MESSAGE('A second message')" is deactivated, I get an error which says „The following UI handlers were not executed: SecondMsgHandler“. Obviously I don’t understand how and when the message handlers are triggered and how the messages are tied to a specific handler if more than one handler is present..... Maybe some of you knows more about it.
Thx in advance
Thomas
0
Comments
-
I can answer your second questions fast. You can only have one handler of each type. That is a limitation in the implementation.Eric Beran
Software Design Engineer II
Dynamics NAV Office 365
Microsoft
This posting is provided "AS IS" with no warranties, and confers no rights.0 -
Hi Beran
Thanks for your help. Given to the assumption, that we don't want to change existing object code, is there a workaround?
Thanks in advance.
Thomas0 -
Hi Ta5,
Question 1:
Test fails, because FirstMsgHandler throws an error because of wrong text. How to fix? Can one test function properly handle more than 1 message? Or should the MessageHandler handle more than 1 text?
The first messagehandler will catch both messages. You can use enqueue/dequeue to identify the text of the expected message, something like this:
LibraryVariableStorage.Enqueue('A first message');
MESSAGE('A first message');
LibraryVariableStorage.Enqueue('A second message');
MESSAGE('A second message');
And then in the messagehandler you can do like
LibraryVariableStorage.Dequeue(TheMessage);
IF _Msg <> TheMessage THEN BEGIN
ERROR('Unexpected msg in MsgHandler');
1
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 333 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions