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.

  • Suggested answer
    Olister Rumao Profile Picture
    3,959 on at
    RE: Testing function for BC.

    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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

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

#1
YUN ZHU Profile Picture

YUN ZHU 374 Super User 2025 Season 1

#2
Mansi Soni Profile Picture

Mansi Soni 247

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 231 Most Valuable Professional

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans