web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

Understanding the Test Codeunit returning SUCCESS and FAILURE messages – Microsoft Dynamics Business Central

Syed Mehdi Profile Picture Syed Mehdi 5

When a Test Codeunit is executed, the platform will Execute the OnRun trigger and each test functions that resides in the Test Codeunit are executed after that. The results of each test functions are recorded in a buffer.

When a SUCCESS is returned by a test, this means that no error occured in the execution of the test.

Similarly, when a FAILURE is returned, the test execution did throw an error. But, the interesting thing here is that, when the test fails even then the execution of the Test Codeunit doesn’t gets terminated. It continues to execute the Test function.

Let’s demonstrate this with two simple tests, one returning SUCCESS and other one returning FAILURE:

codeunit 60000 MyFirstTestCodeunit
{
Subtype = Test;
[Test]
procedure MyFirstTestFunction()
begin
Message('MyFirstTestFunction');
end;
[Test]
procedure MySecondTestFunction()
begin
Error('MySecondTestFunction');
end;
}

Now you can Run the Test.

As test functions are executed from top to bottom, the message thrown by FirstTestFunction will show the following screenshot first:

After finishing the execution of the Test, it shows the SUCCESS and FAILURE statuses of each sub-tests available in the Test Codeunit as functions, as shown in the following message:

The error message that you see above did not appear like a message box, but it is collected in a buffer and recorded as a part of the result of a failing test.

Hope that gives a clear idea about how a Test Codeunit works and how it generates the results. Please comment below if you have any questing regarding this blog or any suggestions related to the topic.

Thanks for Reading!


This was originally posted here.

Comments

*This post is locked for comments