We're here to help

Salesforce DX integration using ANT

Provar and Salesforce DX can be used together to generate a scratch org, push the latest Salesforce customization and run Provar tests inside the scratch org to get functional testing insights. This allows immediate feedback during a development cycle or when a scratch org is used as a system integration test environment.

For Provar customers already using our ANT option to execute tests on servers or locally, Provar supports integration with Salesforce DX scratch orgs using our ConfigureDX option. 

 

Prerequisites


The following prerequisites must be completed before setup.

  1. The scratch org needs to be set up including deployment of the org configuration to be tested
  2. A password should be generated for the scratch org.
  3. The scratch org’s DevHub alias must be the same as the Salesforce org username in your Provar test project..
  4. The Salesforce DX project should be authenticated on the machine where Provar is installed.

 

Setup


To support Salesforce DX in Provar ANT, it is necessary to add a new ANT task after generating the Build File. This ANT task will create a new Provar Environment and add the necessary connection overrides to run Provar against the scratch org with the corresponding DevHub alias . Use this task prior to the Provar Runner Task to create/update the environment.

You can then copy and paste the following into the build file, adding your own information where shown.

<taskdef name="Provar-ConfigureDx" classname="com.provar.testrunner.ant.ConfigureDxTask" classpath="${provar.home}/ant/ant-provar.jar;${provar.home}/ant/ant-provar-bundled.jar;${provar.home}/ant/ant-provar-sf.jar"/>

<Provar-ConfigureDx testEnvironment="<env-name>" provarHome="${provar.home}" projectPath="${testproject.home}" adminUser="<admin user of scratch org>"/>

 

The following errors will be thrown in the ANT log file if the provided details are not correct:

  • An error will be thrown if no users are found in the scratch org with that admin user
  • An error will be thrown if the passwords are not generated for the required users
  • A warning will be logged if the alias is not found

 

Additional logging


You can enable additional logging for the location of the .sfdx folder, authorization, commands which Provar uses in Salesforce DX and the command output.

To get these additional logs, add one additional argument to the ConfigureDx ANT task you added above.

testOutputlevel=”FINE”

This will get the location of the .sfdx folder, the commands and authorization used and their output in the logs.

The output will look like this:

The .sfdx folder and authorization will look like this:

Alternatively, if the log level is not explicitly set to FINE, the output of the Configure-Dx task will look like this:

Demo video


Watch the video below to see Salesforce DX integration in action: