In Microsoft Dynamics NAV 2013 R2, you can create test codeunits and create test functions in 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
In the development environment, on the Tools menu, choose Object Designer.
In Object Designer, choose Codeunit, and then choose New.
On the View menu, choose Properties.
In the Properties window, in the Subtype field, select Test to specify that this is a test codeunit.
On the View menu, choose C/AL Globals.
In the C/AL Globals window, on the Functions tab, enter the names of the test functions in this test codeunit.
For each test function, select the function, choose View, choose Properties, and then verify that the FunctionType property is set to Test.
In the Properties window, choose how you want to commit changes to the database during the test by setting the TransactionModel Property.
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.
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.
Note Test functions must not have parameters or return values.
On the File menu, choose Save. In the Save window, verify that the Compiled check box is selected, and then choose the OK button to save and compile the test codeunit.