4 min read time

How to Run UFT One Tests using GitHub Actions

by   in DevOps Cloud

This article provides an example with basic steps and screenshots showing how to create a GitHub Action that can manually trigger UFT One tests on a remote Windows machine.

Prerequisites

  • A GitHub account with permission to create Actions on a target repository.

Create an action

Perform the following steps to create an action you can use to run UFT One tests.

Set up a self-hosted runner

Follow the GitHub documentation to create a runner hosted on the UFT One machine. The runner handles GitHub requests and directs them to UFT One when necessary.

   https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners

   https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners

You can see the runners you create in the Settings -> Actions/Runner page of your repository.

Create an action

Follow the GitHub documentation to create an action.

   https://docs.github.com/en/actions/quickstart

Design your action to run UFT One tests

The remainder of this document describes a sample action, designed to run a set of simple tests.

Follow this example action and design your own.

  • The repository containing the tests run by the sample is located here: https://github.com/MicroFocus/uft-one-tests
  • The following image shows the runner created for this sample, as displayed on the Settings -> Actions/Runner page:

Sample YAML action script

This is the YAML script used in the sample. It includes jobs that retrieve the UFT One tests, create a property file that controls the test run, get the UFT Tools Launcher, and then run the tests.

https://github.com/MicroFocus/uft-one-tests/blob/main/.github/workflows/main.yml

You can create a similar script, updating the values of the variables PROPS_TXT and RES_XML from the env section as required.

name: Run UFT One Tests Action
# Controls when the action will run. Workflow runs when manually triggered using the UI or API.

on:
  workflow_dispatch:

env:
  PROPS_TXT: PropsMultiTests.txt
  RES_XML: ResultsMultiTests.xml
  LAUNCHER_EXE: FTToolsLauncher.exe
  LAUNCHER_URL: https://github.com/MicroFocus/ADM-FT-ToolsLauncher/releases/download/v1.0-beta-rev12/FTToolsLauncher_net48.exe

defaults:
  run:
    shell: pwsh
    working-directory: ..\

jobs:
  getUftTests:
    runs-on: self-hosted
    steps:
    - name: Display the working directory
      run: echo "$pwd"
    - name: Checkout current repo
      uses: actions/checkout@v3
      with:
        ref: ${{github.ref_name}}
        clean: false

  createPropsFile:
    runs-on: self-hosted
    needs: getUftTests
    steps:
    - name: Create properties file
      run: |
        @"
        runType=FileSystem
        Test1=$($pwd.Path.Replace('\', '\\'))
        resultsFilename=$env:RES_XML
        "@ > $env:PROPS_TXT
    - name: Check properies file
      run: TEST-PATH $env:PROPS_TXT

  getFTToolsLauncher:
    runs-on: self-hosted
    needs: getUftTests
    steps:
    - name: GET FTToolsLauncher.exe
      run:  if (TEST-PATH $env:LAUNCHER_EXE) {
              echo "FTToolsLauncher.exe already exists"
            } else {
              curl -L -o $env:LAUNCHER_EXE $env:LAUNCHER_URL
            }

  runUftTestsFromFileSystem:
    runs-on: self-hosted
    needs: [getUftTests, createPropsFile, getFTToolsLauncher]
    steps:
    - name: Run FT tool
      id: run-tests
      run: |
        $p = Start-Process -FilePath "$env:LAUNCHER_EXE" -ArgumentList "-paramfile $env:PROPS_TXT" -Wait -PassThru -NoNewWindow
        "X=$($p.ExitCode)" >> $env:GITHUB_OUTPUT
    - if: ${{steps.run-tests.outputs.X != 0}}
      uses: actions/github-script@v6
      with:
        script: |
          core.setFailed('The job runUftTestsFromFileSystem failed with status ${{steps.run-tests.outputs.X}} !')       

The local working folder for this sample is D:\Work\GitHub\Runner2\_work\uft-one-tests\ and after running the job you can see:

The repository content is downloaded here, and the script is instructed to run all tests from this folder:

The PropsMultiTests.txt content is defined by createPropsFile job and will be saved like this:

runType=FileSystem
Test1=D:\\Work\\GitHub\\Runner2\\_work\\uft-one-tests
resultsFilename=ResultsMultiTests.xml

Run your action to run UFT One tests

Run the workflow manually from the Actions page. Select the action and click Run workflow.

The screen captures below represent a sample run of the Run UFT One Tests Action action. You can see similar results in your own repository.

Summary diagram:

The getUftTests job output:

   

 The createPropsFile job output:

The getFTToolsLauncher job output: 

The runUftTestsFromFileSystem job output:

To learn more about UFT One, visit the UFT One product page, or browse the UFT One Online Help. Click here for a free 30-day trial of UFT One.

Labels:

Functional Testing