I get asked about device licenses in Business Central on a regular basis, and it's true, there are quite a ...
Learn moreCreating a Test Suite by Combining Page Scripts in Microsoft Dynamics Business Central
Friday, July 19, 2024
Reading time: 3 minutes
In Microsoft Dynamics Business Central, the ability to automate and streamline your processes through scripting is invaluable. By combining smaller scripts into a comprehensive test suite, you can ensure that your business processes are running smoothly and efficiently. In this post, we’ll explore what a test suite is, why it’s beneficial to create smaller scripts, and how to combine them into a test suite using YAML files.
What is a Test Suite?
A test suite is a collection of test scripts that are designed to validate the functionality and performance of a system. By running a series of tests, you can ensure that different parts of your system are working correctly and that recent changes have not introduced any new issues. A well-organized test suite can save time, reduce errors, and improve the overall quality of your system.
Benefits of Smaller Scripts
Creating smaller, focused scripts has several advantages:
- Ease of Maintenance: Smaller scripts are easier to understand, update, and debug.
- Reusability: Individual scripts can be reused across different test suites and scenarios.
- Modularity: By breaking down complex processes into smaller steps, you can test each step independently before combining them.
Step-by-Step Guide to Combining Scripts
Recording and Exporting Scripts
- Record the Scripts: Use the Business Central recording tool to capture each step of your process. For example, record a script to open the customer list and filter to a specific customer, and export it as Step1.yml.
- Export the Script: Save the recorded script to a specific directory.
- Repeat for Additional Steps: Record and export additional scripts, saving them as Step2.yml, Step3.yml, and so on.
Combining Scripts into a Test Suite
Once you have your individual scripts, you can combine them into a single test suite.
- Create a Master YAML File: In the same directory where your step scripts are saved, create a new YAML file, Master.yml.
- Include Individual Scripts: In the Master.yml file, include each of the step scripts. Your master file might look something like this:
name: Master description: Test recording start: profile: BUSINESS MANAGER EVALUATION steps: - type: include name: Step1 description: Run <file>Step1</file> file: .\Step1.yml - type: include name: Step2 description: Run <file>Step2</file> file: .\Step2.yml
Tips for Successful Script Combination
- Start and End on the Role Center: Always begin and end your scripts on the Role Center in Business Central. This ensures that scripts can be combined in any order without issues.
- Create Data Used in Scripts: To ensure repeatability, create the data you use in your scripts. This avoids problems caused by changing data, such as customers exceeding their credit limits or running out of stock.
- Keep Scripts Small and Purposeful: Focus each script on a specific task. This makes them easier to manage and combine.
Disclaimer
This guide is based on version 24 of Business Central, and the Page Scripting Tool is currently in preview. Features and functionalities may change in future releases. For now, this method allows you to combine scripts into a test suite effectively.
Feedback and Future Improvements
Your feedback is valuable in shaping the future of the Page Scripting Tool. Please share your thoughts and suggestions on the BC Ideas page. Together, we can enhance this tool for the entire Business Central community.
Conclusion
Combining smaller scripts into a test suite is a powerful way to ensure your Business Central processes run smoothly and efficiently. By following the steps outlined above, you can create a modular, maintainable, and reusable test suite that saves time and reduces errors. Happy scripting!
Meet Berny During, our Partner Technology Strategist for Business Central at Companial. With over 27 years of experience as a Microsoft Certified Trainer, he brings a wealth of expertise and knowledge to his role. Starting as a Product Manager at Navision South Africa and subsequently at Microsoft, he later established his own successful partner. Joining Companial as a franchisee in the Middle East-African market, Berny once again played a crucial role in guiding partners to grow and develop their Business Central practices through mentoring and training. He holds qualifications in Business Management, Taxation, Law, Supply Chain Management, and Computer Sciences.
More about Business Central
Business Central 2024 Release Wave 2 Preview Version is Now Available!
The preview version of Microsoft Dynamics 365 Business Central 2024 Release Wave 2, also known as version 25, has officially ...
Learn moreDeep Dive: Managing Updates in Business Central 2024 Release Wave 2
In my previous series of four blogs, I provided an overview of the exciting changes coming to Microsoft Dynamics Business ...
Learn moreCoPilot Changes in Business Central 2024 Release Wave 2 (v25)
As we delve into the final instalment of our blog series on the upcoming features in Microsoft Dynamics 365 Business ...
Learn moreArchitectural Enhancements in Business Central 2024 Release Wave 2 (v25)
As we continue our exploration of the upcoming features in Business Central 2024 Release Wave 2 (v25), this third blog ...
Learn moreFirst Look: Exciting New Development Features in Microsoft Dynamics Business Central 2024 Release Wave 2 (v25)
Microsoft Dynamics Business Central continues to evolve, and the upcoming 2024 Release Wave 2 (v25) is packed with new development ...
Learn more