NoteNote

The content in this topic only applies to Microsoft Dynamics NAV 2009 SP1. For Microsoft Dynamics NAV 2009 content, see Developer and IT Pro Help for Microsoft Dynamics NAV 2009.

In Microsoft Dynamics NAV 2009 SP1, you can create test codeunits and create test functions within the test codeunits.

When you create a new function in a test codeunit, the FunctionType property is set to Test by default.

To create a test codeunit and test functions

  1. On the Tools menu, click Options.

  2. In the Options window, in the Show C/AL Testability properties field, enter Yes, and then click OK.

  3. In the Classic client, on the Tools menu, click Object Designer.

  4. In Object Designer, click Codeunit, and then click New.

  5. On the View menu, click Properties.

  6. In the Properties window, in the Subtype field, select Test to specify that this is a test codeunit.

  7. On the View menu, click C/AL Globals.

  8. In the C/AL Globals window, on the Functions tab, enter the names of the test functions in this test codeunit.

  9. For each test function, select the function, click View, click Properties, and then verify that the FunctionType property is set to Test.

  10. If any test functions need UI handlers, then enter the names of the handler functions in the C/AL Globals window. For more information, see How to: Create Handler Functions.

  11. In the C/AL Editor, enter code for each test function and handler function that you defined. You can also enter code in the OnRun function. The OnRun function runs when you execute the codeunit and before the test functions run.

    NoteNote

    Test functions must not have parameters or return values.

  12. On the File menu, click Save. In the Save window, verify that the Compiled check box is selected, and then click OK to save and compile the test codeunit.

See Also