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 :
Business Central forum

Planning tests before developing?

(0) ShareShare
ReportReport
Posted on by 35

Hi,

I am working with automated testing for extensions in Business Central. Until now I had a lot of problems with testing the code, because I realized I can't reach all variables whenever I want. For example, if I am testing one function in a codeunit and after the test of the function ends I can't reach any variables from that codeunit anymore because of the "test isolation" is set on "a codeunit" and results are rolled back every time. So whenever the codeunit goes out of the scope I lose data. At this point, I realized I can bind codeunits and keep the session alive until I need, but I still have problems reaching variables type of record. Other types of variables are easy to reach. 

I also tried to use events but it looks like I can't use them. Or am I may be wrong? I would like to hear from someone, how you are dealing with testing code in Navision (AL code). How do you test data, when you have to process more codeunits at once? 


In case there is no other smart way to perform testing I think is the only way to refactor the code and do it again, knowing what we will test later and how. That means we have to change mostly all functions in the feature that they will return something to work with or at least expose some variable as public or even prepare "return methods" to make testing easier. 

I also think it is really important to think about testing at the beginning of the development process. You need to know what your feature will do, what kind of data will be traveling through, what to expect as input, output and how functions will behave, what are the smart ways to perform testing. This part is really hard because it takes a little bit more time that usually if we perform planning without testing part. When planning tests you need to have the whole image of the feature how it will work. Planning takes a while because you need to think about many options in advance. Maybe you won't find all the options for testing at the beginning but it will be a good start to know the basics of feature behavior and you can write more test while developing process advance.

If someone else I also working with automated testing I would like to have a word because I am lost after switching from testing in Python to Navision, the principles are totally different and I am kinda stuck with codeunits and idea of how to reach variables after the test ends.

Categories:

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