Build from Source

Building the Open Source Version of Test Engine

This guide provides instructions for building the open source version of the Test Engine from source. The open source version includes the latest features, supports, and an open source pull request approach for new changes to be reviewed and merged if they align with the product direction. The main branch is synchronized with the internal build process to distribute release builds as part of the pac CLI. The open source version is a great way to understand and extend the Test Engine and contribute to the wider testing community.

Hosting Options

Depending on your options available you have a have a range of different hosting options to carry out a build from source strategy

Hyper-V

If you are Windows and have Hyper-V enabled as a service you could take advantage of building Virtual Machines to create isolated machines. You can use the Create a virtual machine in Hyper-V.

NOTE: You will need to expand the disk size required for Ubuntu Hyper-V machine, for example selecting 20GB should provide enough disk space.

Cloud Hosted Machines

You can select from a range of cloud hosted machines like Quickstart: Create a Windows virtual machine in the Azure portal

Power Automate Desktop

You can also take advantage of Power Platform Hosted Machines for integrated solution with the Power Platform to have a Domain Joined Windows 11 Cloud PC.

Windows Build

Using Windows 11 as an example you can use the following steps to build from source

  1. Download PAC CLI https://learn.microsoft.com/power-platform/developer/howto/install-cli-msi

  2. Get Git so we can clone the samples

winget install --id Git.Git -e --source winget
  1. Get Visual Studio Code so that can edit config file
winget install -e --id Microsoft.VisualStudioCode
  1. Get the Azure CLI So that we can get access token for Dataverse to store key
Winget install -e --id Microsoft.AzureCLI
  1. Get New Version of PowerShell Core
winget install --id Microsoft.PowerShell --source winget
  1. Get .Net 8.0 SDK Require for this build
winget install Microsoft.DotNet.SDK.8

Ubuntu 22.04 Build

Using Ubuntu 22.0.4 LTS as an example you can use the following steps to build from source

  1. Ensure you have latest updates and upgrades applied
sudo apt update
sudo apt upgrade
  1. Install Git it is not installed
sudo apt install git 
  1. Install Visual Studio code using snap
snap install code --classic

NOTE: The classic flag is required as Visual Studio Code needs full access to the system similar to a traditionally installed application

  1. Install Power Shell
snap install powershell --classic
  1. Install DotNet 8.0 SDK
snap install dotnet-sdk --classic
  1. Install Azure CLI
snap install curl
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
  1. Install the Power Platform CLI
dotnet tool install --global Microsoft.PowerApps.CLI.Tool
  1. Setup Environment Variables in your ~./.bashrc file
export PATH="$PATH:~/.dotnet/tools"
export DOTNET_ROOT=/snap/dotnet-sdk/current
  1. Setup defaults for Powershell. Create the following file ~/.config/powershell/profile.ps1 using Visual Studio Code
# Add .dotnet/tools to the PATH environment variable
$env:PATH += ":$HOME/.dotnet/tools"

# Set the DOTNET_ROOT environment variable
$env:DOTNET_ROOT = "/snap/dotnet-sdk/current"
  1. Ensure that you have enough disk space allocated to build the solution.

Verifying Your Environment

To verify your selected environment has all the prerequisite tools required

  1. Verify that you can launch the Power Platform Command Line Tool
pac auth help
  1. Verify you have a version of git client installed
git --version
  1. Verify Visual Studio Code or alternative text editor is installed
code
  1. Verify that the Azure CLI has been installed
az --version
  1. Verify that PowerShell Core has been installed
pwsh --version
  1. Verify that the .Net 8.0 SDK has been installed
dotnet --list-sdks

Getting Sample Going

The following steps give an example of running sample from Microsoft Windows.

  1. Clone the repository
git clone https://github.com/microsoft/PowerApps-TestEngine.git
  1. Move to the downloaded repo
cd PowerApps-TestEngine
  1. Change to integration branch
git checkout integration
  1. Open PowerShell (Windows + R)
pwsh
  1. Allow local execution policy on Windows
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
  1. Create a certificate to sign secrets. Using an Admin Version of PowerShell run the following on Windows
$Params = @{
DnsName = @("localhost", "localhost")
CertStoreLocation = "Cert:\CurrentUser\My"
NotAfter = (Get-Date).AddMonths(6)
KeyAlgorithm = "RSA"
KeyLength = 2048
}
New-SelfSignedCertificate @Params

NOTE: For Ubuntu the following could be used to create local certificate

openssl req -x509 -nodes -days 180 -newkey rsa:2048 -keyout mycert.key -out mycert.crt -subj “/CN=localhost”

  1. Sign into your Power Platform Environment(s) that contain login details and environment(s) to be tested
pac auth create --name Dev --environment https://contoso.crm.dynamics.com
pac auth create --name Hosting --environment https://contoso-host.crm.dynamics.com
  1. Sign into Azure Command Line using account that has access to organization. This login could be interactive user or Service Principal.

az login –allow-no-subscriptions

  1. Import the WeatherSample_*.zip from samples\weather into the environment you want to test

  2. Import the TestEngine_*.zip (Will be used to store authentication state)

  3. Add the config to the “samples/weather” folder using Visual Studio Code

{
    "tenantId": "d1234567-1111-2222-3333-4444555666",
    "environmentId": "a000000-1824-e982-98d9-190558c8750f",
    "customPage": "te_snapshots_24d69",
    "appDescription": "Weather Sample",
    "user1Email": "user1@contoso.onmicrosoft.com",
    "runInstall": true,
    "installPlaywright": true,
    "DataProtectionUrl": "https://contoso-host.crm.dynamics.com/",
    "DataProtectionCertificateName": "CN=localhost",
    "pac": "optional/pac.exe",
    "auth": "certstore",
    "authstate": "dataverse"
}

NOTE:

  1. The pac parameter is optional and only needed if needing to use a specific version of pac cli
  2. Can use auth value of certenv for based64 version of X.509 certificate to encrypt/decrypt
  3. If using auth value of certenv the DataProtectionCertificateName is not required
  4. You can use an authstate of storagestate on windows for local Data Protection API encrypted login details
  5. The export.ps1 can be sued to export the local certificate for use on another machine

Run the Sample

  1. Open pwsh session

  2. Change to samples/weather

cd samples/weather
  1. Run the test using your configured config.json in samples\weather
pwsh -File RunTests.ps1