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

Announcements

No record found.

News and Announcements icon
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
    4,009 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,028 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,121 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 669 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans