13

We have a page that requires an initialisation before it is called. We do this with an action that calls an MyPage.InitValues(SomeValues) procedure and then calls MyPage.RunModal.


Such a page is impossible to test because we cannot call the InitValues procedure on a TestPage even though the procedure is callable from within the Page.

Category: Development
STATUS DETAILS
New

Comments

D

I tried to get around this restriction by creating a page extension on the page that includes a text field that I can put a value in that will trigger the function to be called. I think you will agree this feels like a hack to get around the limitations of the platform.This method does not allow the field to be set prior to opening the page, which means if my page checks to see if it has been initialised in an OnOpenPage trigger, it will still not work.I figured I could raise an IsHandled type even before calling the code in the OnOpenPage so I could use a manually bound codeunit subscriber to force the page to not call the OnOpenPage code until I have had chance to use my field hack to call my initialise code. This requires changing the object under test too much.One easy way to deal with this requirement would be to make it so that an instance of a Page object can be assigned to a TestPage and vice-versa. This would mean I could do the following:RealPage.InitialiseValues(SomeValues);TestPage := RealPage;TestPage.Edit();// do my automated testRealPage := TestPage;RealPage.GetSomeValues(SomeValues);Either approach would work. At the moment I am stuck with an untestable page.

Category: Development