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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Testing function for BC.

(0) ShareShare
ReportReport
Posted on by 358

I have an Action called 'Submit' on my card page. If this button is pressed without having line items it throws an error.
I am writing a test to test this functionality in the following way but failed.

[Test]
[Scope('OnPrem')]
procedure MyTest()
var
MyCardPage: TestPage "MyCardPage";
begin

MyCardPage.OpenEdit();
Asserterror MyCardPage.Submit.Invoke();
Assert.AreEqual(GETLASTERRORTEXT, 'There is nothing to release for the document of type %1 with the number %2.', 'Invalid error message.');

end;

What is happening is, once the MyCardPage.Submit.Invoke(); is getting executed, it takes me to code where the actual error is being thrown. I expected it to pass the test since it is an AssertError.

Any guidance as to how can I write this test will be highly appreciated.

I have the same question (0)
  • Suggested answer
    Olister Rumao Profile Picture
    3,967 on at

    Hi Mesam,

    Assert Error is use where you know there is going to be an error and the execution doesn't stop on the error but moves to the next step.

    As far as what it looks is that there is something missing because of which AssertError is not working to block the error and continue execution.

    Thus, you are taken originally to where the error is occurring.

    Refer docs.microsoft.com/.../devenv-extension-advanced-example-test

    Let me know if you need help.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,135

#2
YUN ZHU Profile Picture

YUN ZHU 733 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 612

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans