Automated Testing
Automated testing is the application of software tools to automate a human-driven manual process of reviewing and validating a software product. Most modern agile and DevOps software projects now include automated testing from inception - and Altus is no different.
To assist with conducting Altus customisations via modern Agile processes, we include access to the Automated Test Suite for Altus. These tests use a variety of technologies including reqnroll and Playwright to automate the validation of Altus environments.
How to Clone the Repository and Setup Visual Studio
Pre-requisite: Visual Studio 2022 is installed with .NET desktop development.

Steps:
Open Visual Studio.
Sign In using Microsoft account.
Click on "Clone a repository".

Enter the following details then click on "Clone":
Repository location: "https://ipmo.visualstudio.com/Sensei.Kaizen.AutomationTests/\_git/Altus.Regression.Suite".
Note
This step can only currently be done by Partner consultants. We are considering moving this to a public repository over time.
Path: Desired folder location.

Login using Partner account (user should have access to the repo).
You should see "Altus.Regression.Suite" solution in the Solution Explorer.

(Optional) Add reqnroll as an extension (Note: You only need to do this once for your Visual Studio instance):
- Navigate to Extensions menu > Manage Extensions.

- Click on "Online" tree view on the left-hand navigation pane.
- Type "reqnroll" in the Search box on the right-hand navigation pane.
- Select "Reqnroll for Visual Studio 2022" in the search results.
- Click on Download.


- After the download completes, close Visual Studio.
- The VSIX installer pop-up will appear, click on "Modify".

- Close VSIX installer once the process is completed.

- Navigate to Extensions menu > Manage Extensions.
Re-open Visual Studio and add an environment config file:
Open the user secrets in Visual Studio of the project.
Update the config file using the below template then save changes. See reference document: Setting up credentials in Key Vault
{ "Environment": "<EnvironmentName>", "Headless": "false", "Browser": "msedge", "Tracing": "false", "<EnvironmentName>": { "UseKeyVault": "<yes/no>", "KeyVaultUri": "<keyVaultUri>", //required if UseKeyVault is yes "KeyVaultClientId": "<AzureAppClientId>", //required if UseKeyVault is yes "KeyVaultSecret": "<AzureAppSecret>", //required if UseKeyVault is yes "KeyVaultTenantId": "<AzureTenantID>", //required if UseKeyVault is yes "TargetURL": "https://<TargetEnvironment>.dynamics.com/", "AuthUsername": "<UserName>", //required if UseKeyVault is no "BaseAuthPassword": "<PasswordInBase64>", //required if UseKeyVault is no } }Sample:

If not displayed, open the Test Explorer from the View menu.

Parameter Change to Run the Tests with the Browser Open
By default, the tests will run in headless mode, meaning you will not see the browser as the tests are being executed. If you want to run the tests in headful mode (with the browser open), follow the steps in this section. Otherwise, skip to the next section Running the Tests.
- Open the user secrets in Visual Studio of the project.
- Set
Headlessparameter tofalse.
Running the Tests
- Build the solution via Build > Build Solution. Once successful, the tests will appear in the Test Explorer.

- Expand on the arrows on the Test Explorer pane to display the tests.
- Right-click on a test (you can select multiple tests by holding shift or control on the keyboard) and then click "Run".

- The test will start to be executed indicated by the "running" icon on the test. Note: If the tests are run in headful mode, the browser will close after logging in to Altus. This is expected as the tests are using a global sign in method. A new browser will open with a signed-in state to run the actual test.

- Once the test run is complete, passed tests will have a green tick indicator. You can also see the run results on the Tests section of the Output pane.
If the Output pane is not open, click View menu > Output. Select Tests from the "Show output from:" dropdown.

- To check test screenshots, navigate to the Screenshots folder of your project folder. The screenshot file name will be the same as the test name, prefixed with a timestamp and a "pass" or "FAIL" as appropriate.

Generating Reports
The results will be displayed in Test Explorer. Including links to pictures.
If Tracing is enabled in the configuration a Trace zip package is created by the tests in the output folder \bin\Debug\net8.0-windows8.0\traces. The Trace can bests be viewed with the Playwright Trace Viewer.s
Setting up Credentials in Azure Key Vault Secrets
Pre-requisite
User would need to have an Azure role assignment to be able to create Key Vaults.
Part I: Creating an Azure Key Vault
- Login to Azure Portal.
- Go to Key Vaults by searching for "key vaults" on the search bar and clicking on the search result.

- Click Create.

- Populate the required details on the Basics tab. Once done, click the Tags tab:
- Project details
- Subscription: "your subscription"
- Resource group: "your resource group"
- Instance details
- Key vault name: "name of your key vault"
- Region: "your region"
- Pricing tier: Standard
- Recovery options – you can update this if you want but using the default values is fine.

- Project details
- Add a tag pair (in this key vault example we have Name: Environment and Value: Development). Once done, click Review + create.

- Click Create.

- Once the deployment is complete, click on Go to resource.

- Take note of the Vault URI and the Directory ID. You will save these values in the config file for the parameter KeyVaultUri and KeyVaultTenantID.

Part II: Create Key Vault Secrets for your username and password
- Click Secrets on the left pane and then click Generate/Import.

- Populate the required details and click Create:
- Name: AuthUsername
- Secret value: "your username"

- Create another secret for your password with the details:
- Name: AuthPassword
- Secret value: "your password"
- You should have 2 entries on your Key Vault Secrets once done.

Part III: Give an AAD Application permission to access Key Vault Secrets
Pre-requisites
- An AAD Application has already been created to be used to access the Key Vault. We will use "Automation – Selenium Tests"
- A client secret has been generated for the AAD Application. Request this information from the AAD Application owner
- Click Access policies on the left pane and then click Create.

- On the Permissions tab, tick Get and List under the Secret permissions column and click Next.

- On the Principal tab’s search bar, search for the AAD application you want to give access to your Key Vault.
- Select the AAD application and click Next.

- Click Next on the Application (optional) tab.

- Click Create.

- You should see the application appear on the Access policies of your key vault.

Part IV: Using your Key Vault for the automation tests
Update the Key Vault related parameters in your config.json1 file:
- KeyVaultUri – from Part I, Step 8
- KeyVaultTenantID - from Part I, Step 8
- KeyVaultClientId – request this from your AAD Application owner
- KeyVaultSecret – request this from your AAD Application owner
"UseKeyVault": "yes",
"KeyVaultUri": "<keyVaultUri>",
"KeyVaultClientId": "<AADAppClientId>",
"KeyVaultSecret": "<AADAppSecret>",
"KeyVaultTenantID": "<AADTenantID>