Creating a Test Page in Dynamics NAV

You can create and open a test page in the following ways:

To declare a test page variable

  1. Create a test codeunit. For more information, see How to: Create Test Codeunits and Test Functions.

  2. In Object Designer, on the View menu, choose C/AL Globals.

  3. In the C/AL Globals window, on the Variables tab, enter the following:

    1. In the Name column, enter a name for the test page variable.

    2. In the DataType column, select TestPage from the drop-down list.

    3. In the Subtype column, select the page that you want to test with the test page variable.

Example

This example shows how to use the OPENEDIT function to open a test page. It also shows how to use the TRAP function to trap a call to open a test page so that the opened page is assigned to a variable.

This example requires that you create the following variables.

Variable name DataType Subtype
CustomerCard TestPage Customer Card
CustomerStatistics TestPage Customer Statistics
ShipToAddressList TestPage Ship-to Address List
CustomerCard.OPENEDIT;  
// Test Customer Card page  
CustomerStatistics.TRAP; // The next page that is invoked will be trapped and assigned to the CustomerStatistics variable.  
CustomerCard."Page Customer Statistics".INVOKE; // Invokes an action from the Customer Card page.   
CustomerStatistics."Balance (LCY)".ASSERTEQUALS(0); // Now that the CustomerStatistics test page is open, you can use the variable to test the page.  
ShipToAddressList.TRAP; // The next page that is invoked will be trapped and assigned to the ShipToAddressList variable.  
CustomerCard."Page Ship-to Address List".INVOKE; // Invoke an action from the Customer Card page.  
// Continue testing  

If the Balance (LCY) value for the customer whose card page you opened is 0, then the test result is SUCCESS, and you get a message that is like the following message.

Test Code Unit 50001 TestBalanceLCY

OnRun: SUCCESS

SUCCESS

If the Balance (LCY) value for the customer whose card page you opened is not 0, then the test result is FAILURE, and you get a message that is like the following message.

Test Code Unit 50001 TestBalanceLCY

OnRun: FAILURE

AssertEquals for Field:Balance (LCY) Expected = ‘0,00’, Actual = ‘1.499,02’

FAILURE

See Also

Testing the Application