Use Jenkins to trigger local UFT One tests

This topic describes how to run UFT One tests stored on your local machine.

Run local UFT One tests

Configure a Jenkins build step to run one or more local UFT One tests.

To configure a Jenkins build step to run UFT One tests

  1. In the Project Configuration section of the Jenkins job, scroll down to the Build section, click Add build step, and select Execute Micro Focus tests from file system for a freestyle project.

    Note: For a pipeline, in the Pipeline Syntax page, select runFromFSBuilder or UFTScenarioLoad from Sample Step drop-down, generate the script, and copy the script to the pipeline script box.

    The UFTScenarioLoad option is obsolete and is supported for backwards compatibility only.

  2. In the Tests box, enter a test with its full absolute path, a folder, or MTB containing one or more tests.

    To specify multiple entries, click the down arrow on the right of the field and enter each test path on a separate line. Make sure that the paths are accessible from all machines in the local network.

    Tip: Alternatively, indicate a batch file that contains a list of tests, along with their parameters. For details, see Use a batch file to specify multiple tests.

  3. (Optional) Specify test parameters to use in one of the following ways:

    Note:  

    • We recommend specifying test parameters in the table instead of specifying them in the Tests box. The first method, which lets you provide only string or number parameter values, is supported for backward compatibility only.

    • Specify values for all test parameters required by your tests, or make sure that the parameters have default values defined in UFT One.

  4. (Optional) Configure the following settings:

    Results directory Specify the location in which to save the test's results. The result files are named such that they do not overwrite any existing results in that location.
    UFT One parallel running mode

    Select to run your test on multiple environments.

    For more details, see Run tests on multiple environments in parallel.

    Timeout

    Indicate a timeout, in seconds, after which the job will fail.

    Required to configure Jenkins to load UFT One run results for any tests that had completed for this build step, even if a test failed and prevented other tests from running.

    Run Mode

    Define a UFT One run mode for your tests:

    1. Select UFT One-specific settings.
    2. From the Run Mode dropdown list, select Fast or Normal.

    For more details, see Test Runs Pane (Options Dialog Box > GUI Testing Tab).

    Configure failure scenarios

    Configure the actions that UFT One performs in case your test, or a test in your test run, fails.

    For details, see Configure failure scenarios for your test runs.

    Output encoding

    (Plugin version 7.4 and later)

    Select the encoding charset to use for Jenkins Console Output text. The default value is UTF-8.

    Caution: We do not recommend configuring failure scenarios together with parallel test runs. Doing so may cause UFT One to behave unexpectedly.

  5. Click Apply to save your changes and continue with more build steps. Click Save when you are finished adding build steps.
  6. Add a post-build action to define settings for the UFT One test results.

    In the Post-build Actions section, click Add post-build action, and select Publish Micro Focus test results for the freestyle project.

    Note: For a pipeline, in the Pipeline Syntax page, select publishMicroFocusTestResults from Sample Step drop-down, generate the script, and copy the script to the pipeline script box.

    Select one of the following archiving options:

    Archive test reports for failed tests Only save test result reports for failed tests.
    Always archive test reports Always save test result reports.
    Do not archive test reports Never save the test results.
  7. (For a pipeline) To display results of all executed tests in case you abort the pipeline in the middle of the run, insert a try-finally block into the script in the pipeline script box. See the following example:

    Example:

    try {
      runFromFSBuilder fsTests: 
      '''C:\\JenkinsTestsFromFS\\TestToFail''',
      uftSettingsModel:[
        cleanupTest: '', fsTestType: 'Rerun the entire set of tests', 
    numberOfReruns: '3', onCheckFailedTest: 'true'
        ] 
      } finally {
      publishMicroFocusTestResults 'ALWAYS_ARCHIVE_TEST_REPORT'
    }
  8. Run or schedule the job as you would with any standard Jenkins job.

    When test is completed, continue with Review test run results.

Back to top

Use a batch file to specify multiple tests

Configure the Jenkins job to trigger multiple tests by specifying the tests in a batch file, together with their parameters.

Specify multiple tests, or even the same test several times, each time with different parameters. When specifying the path to your tests, Jenkins environment variables are supported for path names.

Give your batch file an .mtbx extension, and use the following sample syntax:

<Mtbx>
 <Test name="test1" path="c:\tests\APITest1">
 <Parameter name="A" value="abc" type="string"/>
 ….
 </Test>
 <Test name="test2" path="${WORKSPACE}\test2">
  <Parameter name="p1" value="123" type="int"/>
  <Parameter name="p4" value="123.4" type="float"/>
  ….
 </Test>
</Mtbx>

Continue with your build configuration

When you're done defining your batch file, go back to the main build configuration steps.

Back to top

Run tests on multiple environments in parallel

Configure Jenkins to run a series of sequential web or mobile tests, on multiple environments in parallel.

When configured, each test is run sequentially. While running each test, multiple environments are tested in parallel.

Do the following:

  1. In the Execute Micro Focus tests from file system build step, select the UFT One parallel running mode option.

  2. Define one or more environments for each execution set of tests using the UI configuration dialogs.

Note: To run tests on mobile devices, you must have a UFT Mobile connection configured. For details, see Integrate mobile tests and Jenkins.

Define your parallel tests

In the Tests box, enter a test with its full absolute path, or a folder or MTB containing one or more tests.

  • To specify multiple entries, click the down arrow on the right of the field and enter each test path on a separate line. Make sure that the paths are accessible from all machines in the local network.

  • Alternatively, indicate a batch file that contains a list of tests and parameters. For details, see Use a batch file to specify multiple tests.

Define your parallel environments

Do the following:

  1. Select Mobile or Web.

  2. Click Environment wizard to select a browser or device.

  3. Click + Environment to add a new environment for your execution set. UFT One supports up to four parallel test runs.

    If you configure more than four environments, each subsequent environment will wait in queue.

  4. Click + EXECUTION SET to add a new set of tests to run, with their own environments defined.

Continue with your build configuration

When you're done defining your parallel test runs, go back to the main build configuration steps.

Back to top

Configure failure scenarios for your test runs

Configure the actions that UFT One performs in case your test, or specific tests in your test run, fail.

Do the following:

  1. In the Execute Micro Focus tests from file system build step, click the UFT One-Specific Settings button.

  2. Select the On failure option, and then select one of the following:

    Option Description Application Automation Tools plugin version 6.3 or earlier
    Rerun the entire set of tests.

    Select this option to rerun all the tests run by this build job if any of the tests failed.

    Option name is Of any of the build's tests
    Rerun specific tests in the build.

    Select this option to define failure scenarios for one or more specific test only. This enables you to rerun specific failed tests in your test run without having to rerun them all. For details, see Configure failure scenarios for one or more specific tests.

    Option name is Of a specific test in the build
    Rerun only failed tests. Select this option to rerun any and all failed tests. Option is not available.
  3. Select a node to handle rerunning the test or tests.

    Note: Ensure that the node selected here matches the node configured in the General area of the build job configuration. This ensures that the test paths used for the tests run by this job are correct.

    For details, see Use Jenkins to trigger local UFT One tests.

  4. In the Reruns field, define the number of times you want to rerun the test or tests.

  5. In the Cleanup test field, define an optional test to run as a cleanup after the entire test run has finished and a failure has occurred. The test defined is run before each new test rerun, to create the correct environment for the test run.

Configure failure scenarios for one or more specific tests

If you selected the option to rerun only specific failed tests, configure the tests to rerun as follows:

  1. The list of tests displays all tests included in this build job. Select the check boxes for each of the tests you want to rerun if it fails.

  2. Do one of the following:

    Define failure scenarios per test

    For each selected test, define the number of times to rerun the test, and any cleanup test to run before rerunning.

    Copy values to all selected tests

    Copy the main failure scenario defined to all selected tests below.

    Next to the main Reruns field, click the Copy/Paste button.

    To clear all of the per-test definitions, click Clear.

Continue with your build configuration

When you're done defining your failure scenarios, go back to the main build configuration steps.

Back to top

Review test run results

To view your UFT One test results, do the following:

  1. Click the UFT One Report icon in the left toolbar. The UFT One Report page opens with a table listing the test runs (test name, timestamp, status, link to the report, etc.)

    Note: You can specify the timestamp format for each test run on the Jenkins configuration page (Manage Jenkins > Configure System, Run Result (UFT Report) timestamp format string section).

  2. Click on a link to open the desired report:

    • HTML Report: The browser opens the HTML report.

      If you ran multiple tests in parallel, your report includes results from all tests run. For more details, see Sample ParallelRunner response and run results.

    • Run Results Report: The download of the zip file begins. Extract its contents. The extracted zip file contains the result files, viewable in the Run Results Viewer.

Note:  

  • If you are viewing the log for this build job, you will see a number of timeout messages displayed, including PerScenarioTimeout and FileSystemTestRunner.

    The PerScenarioTimeout can be ignored as it is only relevant for LoadRunner Professional tests.

  • You can also add a post-build step to publish a JUnit test result report. This converts the UFT One .xml results file into a JUnit report.

  • If you abort a job in the middle of the test run, the test report displays the results of all tests executed until the stop of the job.

Back to top

See also: