Travis CI Provar Integration Setup Overview

This following provides step-by-step instructions to execute Provar test cases in Travis CI. Travis CI is a hosted continuous integration service used to build and test software projects hosted at GitHub.

For customers wishing to use Provar with the Travis CI Enterprise edition, the steps are broadly similar but since you will be hosting Travis CI on your own infrastructure, please Contact Us for assistance.

 

Prerequisites

(1) Provar ANT zip file.

(2) Provar project with at least one test case and the associated ANT build.xml file.

(3) Github account.

(4) The Provar project is pushed into a nominated Github repository for the above account.

(5) Provar Execution Only (or Floating) license key pushed into the .license folder of the Github repository. Please only upload license keys on private repositories to avoid unlicensed usage by third parties. Unlicensed access will be tracked and can cause you to be locked out of Provar until a new license key is re-issued to you.

 

Steps to an create account in Travis CI

The following steps can be completed using a free Travis CI account. If you have an existing paid account simply log in and jump to step three.

(1) Go to the Travis CI website and click Sign Up.

(2) Click Authorize travis-ci to log in with your GitHub credentials, then enter your GitHub password. You’re actually on GitHub.com at this point. Travis CI never sees your login information.

(3) When you’ve logged in, click your picture to go to profile settings.

(4) Find the Provar project repository and turn on Travis CI for your repo.

Sometimes it takes several minutes to sync Travis CI and Github.

That’s it! You have now set up Travis CI to track changes in your Github repository.

 

Add a .travis.yml file to your repository

In order for Travis CI to build your project, you will need to add a .travis.yml configuration file to the root directory of your repository.

If a .travis.yml is not in your repository, or is not valid a YAML, Travis CI will ignore it.

Here is an example file:

language: java
addons:
  chrome: stable
before_script:
  - "export DISPLAY=:99.0"
  - "sh -e /etc/init.d/xvfb start"
  - sleep 5 # give xvfb some time to start
cache:
  directories:
    - Provar_Home
script:
  - curl -O https://download.provartesting.com/1.9.10/Provar_ANT_1.9.10.02.zip
  - unzip -o Provar_ANT_1.9.10.02.zip -d Provar_Home
  - rm Provar_ANT_1.9.10.02.zip
  - xvfb-run -a ant -f DemoProject/build.xml

 

First, we need to mention which language we want to use. So, it’s Java here for us. By default, Travis CI is going to execute our test cases on JAVA 8 which is the current Provar supported version. 

As we need to execute our UI test cases on a browser, that is why the Chrome add on is included. 

To execute test cases in headless manner, we also need to install xvfb, so before executing the actual test script section we are installing xvfb.  

Caching of Provar_Home directory is optional. It is recommended to enhance the Provar performance within CircleCI.

The script step contains several sub-steps. First, you should download a Provar Execution Only zip file and then unzip it into the Provar_Home location. Then you should remove the zip file since it is no longer required. The final step is the main step which executes the Provar test cases using your build.xml file and tests that are already synchronised in your Github repository.

Please refer to the following link to execute test cases on alternate browser options supported by Travis. 

https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-xvfb-to-Run-Tests-That-Require-GUI-(e.g.-a-Web-browser)

 

Parameter changes in build.xml

(1) First, create an environment variable for Provar_Home location.

 

 

 

 

 

 

(2) Click on More options -> Settings.

(3) Add environment variable “PROVAR_HOME” with the value “\${env.TRAVIS_BUILD_DIR}/Provar_Home”. Click on the Add button.

(4) Then, edit the build.xml file.

The main parameter is to edit is “provar.home” value is the environment variable “PROVAR_HOME”

See the example build.xml.

<project default="runtests">
  <property environment="env"/>
  <property name="provar.home" value="${env.PROVAR_HOME}"/>
  <property name="testproject.home" value="DemoProject"/>
  <property name="testproject.results" value="DemoProject/Results"/>
  <property name="license.path" value="${env.PROVAR_HOME}"/>
  <echo message="provar home is:${provar.home}"/>
  
  <taskdef name="Provar-Compile" classname="com.provar.testrunner.ant.CompileTask" classpath="${provar.home}/ant/ant-provar.jar"/>
  <taskdef name="Run-Test-Case" classname="com.provar.testrunner.ant.RunnerTask" classpath="${provar.home}/ant/ant-provar.jar;${provar.home}/ant/ant-provar-bundled.jar;${provar.home}/ant/ant-provar-sf.jar"/>
  <taskdef name="Test-Cycle-Report" classname="com.provar.testrunner.ant.TestCycleReportTask" classpath="${provar.home}/ant/ant-provar.jar;${provar.home}/ant/ant-provar-bundled.jar;${provar.home}/ant/ant-provar-sf.jar"/>
  
  <target name="runtests">
  
    <Provar-Compile provarHome="${provar.home}" projectPath="${testproject.home}"/>
  
    <Run-Test-Case provarHome="${provar.home}" 
        projectPath="${testproject.home}" 
        resultsPath="${testproject.results}" 
        resultsPathDisposition="Replace" 
        testEnvironment="" 
        webBrowser="Chrome" 
        webBrowserConfiguration="Full Screen" 
        excludeCallableTestCases="true" 
        salesforceMetadataCache="Reload" 
        projectCachePath="${provar.home}/.provarCaches"
        licensePath="${provar.home}/.licenses"
        testOutputlevel="WARNING" 
        pluginOutputlevel="WARNING"
        stopTestRunOnError="false"
        invokeTestRunMonitor="true"
        >
    
      <fileset dir="../DemoProject/tests">
        <include name="GoogleSearch.testcase"/>
      </fileset>
    </Run-Test-Case>

  </target>
</project>

Trigger the first build

We have configured the GitHub App integration, and added a .travis.yml file to your repository, and updated the build.xml. All we need to do now is to commit it to the local git history and push it to GitHub.

After the build is complete , you can check the execution logs in the “Job log” tab and the details of the job will be visible as shown in the screenshot below.

Test Results

After a successful execution, test reports will be generated in the location mentioned in the build.xml “testproject.results” parameter. 

<property name="testproject.results" value="DemoProject/Results"/>

You can refer to the link below for help customizing the reporting options in Provar.

https://provartesting.com/help/testing-with-provar/reporting/

There are multiple ways to export the test results to view them later. For example, you can publish the test results to AWS S3, Github or you can execute a script to upload them to any system or cloud platform you have access to. Please, see the link below for more information:

https://docs.travis-ci.com/user/deployment/