Let's leave something for you to discover. Go to GitHub and have a look at how this is implemented.
In this section, we have learned how to create automatic tests for your extensions according to your business scenarios. Automatic testing is absolutely a must-have with Dynamics 365 Business Central (it's mandatory for AppSource apps, but it's also a best practice to follow in general).