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.
Executes after a test function of a test codeunit has been run.
OnAfterTestRun(CodeunitID : Integer;CodeunitName : Text;FunctionName : Text;Success : Boolean)
The ID of the codeunit that has run.
The name of the test codeunit that has run.
The name of the test function that has run.
This parameter is empty when the OnAfterTestRun trigger is called for the entire test codeunit.
true indicates that the test function run succeeded. false indicates that the test function run failed.
A test runner codeunit manages the execution of test codeunits that are run from its OnRun function. When a test codeunit runs, it executes each test function one at a time in the codeunit. When implemented, the OnAfterTestRun trigger is called after each test function has run and after the entire test codeunit has run.
The OnAfterTestRun trigger suppresses the automatic display of the results message after the test codeunit runs.
To return the error message for a failed test function run, use the.
You can use the OnAfterTestRun trigger to perform postprocessing, such as logging, or to automate tests by integrating the test runner codeunit with a test management framework.
The OnAfterTestRun trigger is run in its own database transaction.
For more information, seeand .
The following OnAfterTestRun trigger code logs test results to a test reporting system. This example requires that you create a record variable named log.
log.INIT; log.UnitId := CodeunitId; log.Unit := CodeunitName; log.Func := FunctionName; log.Before := Before; log.After := CURRENTDATETIME; If Success THEN log.Status := log.Status::Success ELSE BEGIN log.Status := log.Status::Failure; IF FunctionName <> '' THEN log.Message := GETLASTERRORTEXT; END log.INSERT(true);
The GETLASTERRORTEXT function returns the text that was contained in the last error message.