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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

Writing functions for test codeunit

(0) ShareShare
ReportReport
Posted on by

Hey there,

I have finished my extension and it is working in BC, now for uploading it to Appsource, I have to create multiple functions:

The first functions should test, whether I can buy/sell an item or not.

Do you know where to start?!  I have no plan how to do this...

Categories:
I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Malue,

    This is the check list to submit your extension to AppSource : https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-checklist-submission

    and this is an description (+example) on how to create a test package with your extension https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-extension-advanced-example-test

    --

    Don't hesitate If you need more details or explanations.

    -------------

    Please verify my answer if you find my answer helpful. Doing so you'll show other community members that there was found a solution and you credit my help.

    -------------

    Best Regards,

  • Suggested answer
    Mohsin Abbas Profile Picture
    525 on at

    Hi

    Assuming that buy/sell functions are performed through some action on page, you should begin with the following:

    - Create a testpage variable of that particular page.

    - Check that action is visible and enabled (Using Assert)

    - Invoke buy/sell action

    - Verify results by testing data in resulting tables.

    If you could provide more details of your actions, I can provide further help.

    Regards.

  • Community Member Profile Picture
    on at

    Hi, thank you for your explanation. Do you also know how I can test, whether a certain field is implemented on a page of my extension?

  • Community Member Profile Picture
    on at

    Hi malue,

    could you please give us more details in order to understand your needs and get to help you .

    Best Regards,

  • Community Member Profile Picture
    on at

    Hi Nissay,

    I created a table and page extension to extend "item" and "item card". In both I implemented the field "ingredients" and it is an option field. In my test codeunit I want to test, whether that field is implemented on the page "item card". Therefore I have created a global testpage for "item card" to have access to its fields and now I need a function like "Exists" or so to test its existence.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Malue,

    I didn't get very well your need. But:

    1) if you wanna know in your test if the user had selected an ingredient from your ingredients field: use something like:

    ingredients (options: ,Ingredients1,Ingredients2,... )
    
    
    IF Item.ingredients <> Item.ingredients::" " Then  // note you should add an option with one space 
      // It has been selected 


    2) if you mean by it exists or not, the field is visible or not I think because its two properties visible and enabled are true, you don't need to do that. In fact you don't need to test that because you have not to test fields if they are on pages or not in order to submit your extension to AppSource !

    3) You can as well in your test code assign an ingredients and continue testing with ! :

    // Testing code
    Item.ingredients := Item.ingredients::Ingredients1; 
    // Testing Code

    -----

    Best Regards,

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans