Dynamics 365 F&O Apps: Automatically Create Azure DevOps Test Cases without LCS
Overview
I have created a couple of PowerShell scripts to iterate a folder of D365 Finance and Operations developer XML task recordings, parse the XML for the test steps, and upload to an Azure DevOps project as new work items with the type Test Case.
This is useful if you need to avoid using LCS, but want some automation in the creation of your Test Cases in Azure DevOps. This may be because you are using a BPM library not in LCS, or you may be using Power Platform to deploy your D365 environments rather than LCS, or even preparing for the near future where LCS will be deprecated.
The scripts are hosted on GitHub here: https://github.com/anthonyblake/PSD365TestCaseUploader
The project contains 2 main PowerShell scripts.
ADOTestCaseUploader.ps1
This script connects to Azure DevOps via the API and uploads a single pre-formatted test case.
ADOUploadTestXmls.ps1
This script is actually poorly named. It iterates a folder for XML files, which must be developer test XMLs generated from Dynamics 365 Finance and Operations Apps task recordings. For each XML, it opens and iterates the markup looking for test steps, which it adds to a payload ready to be uploaded to Azure DevOps as a test case. It then calls ADOTestCaseUploader to call the Azure DevOps API and upload a new work item with type test case, including a payload which contains the test case steps.
AllowUnsignedScripts.ps1
You may need to run the command in this file to allow you to run the unsigned PowerShell scripts in this repo.
set-executionpolicy remotesigned
This PowerShell script is currently crude. Files aren’t cleaned up after uploading, and there is no error handling. If you are having issues, please reach out, but you may need to tweak the script for your needs.
Prerequisites
- D365 Finance and Operations Apps instance, to create task recordings
- Azure DevOps personal access token
Installation
Clone the repo
git clone https://github.com/anthonyblake/PSD365TestCaseUploader.git
Usage
From Dynamics 365 Finance and Operations Apps, create a number of task recordings using the Task recorder option.
Click +Create recording.
As you navigate and take actions in D365, the actions will appear as task steps in the task recorder. For the example I created a Vendor Group.
At the end of each recording, click “Save as developer recording”. This is the XML containing the test steps we need for Azure DevOps.
Save the recordings to the same folder as the PowerShell scripts from the GitHub repo.
Run the following PowerShell:
#Upload D365 test cases to Azure DevOps
.\ADOUploadTestXmls.ps1 -organisation your_devops_org_name -project your_devops_project_name -pat azure_devops_personal_access_token
This will convert any XMLs in the source folder and upload them to Azure DevOps as test cases.
In Azure DevOps, your Test Cases will be created.
Open one of the test cases, and the steps will match the steps from the task recorder created earlier.
Summary
The PowerShell script is crude but effective, creating Test Cases in Azure DevOps in bulk via automation, without the need for LCS. If you find this useful, let me know via the contact details at the bottom of the page!