Apex execute
This test step executes a Salesforce Apex code block as a Test Step for the defined Salesforce connection. This is useful for triggering a batch job to run immediately.
In Salesforce, Apex Execute is sometimes known as Anonymous Blocks.
Locate the Apex Execute test step in the Test Palette and drag it into the test case:
Update the following parameters:
- Connection Name: Choose the Salesforce connection for which the Apex code needs to be executed
- Apex Code: Write or paste the Salesforce Apex Code block you wish to execute. Retain the syntax as per standard Salesforce Apex
- Result Name: The string returned from Salesforce on running the Apex code
- Result Scope: The scope of use of this output variable
- Regular Expression: Filters the result string output based on this regular expression
Then save the Test case.
Apex Execute example
The test case in the screenshot above updates the title field on contacts in Salesforce by executing the Apex code block. Note the use of Regular Expression in the Results section to extract the result of the Apex query which gives a Success on successfully updating the contacts. This in turn is asserted in Provar, and the test is failed if a Success is not received as output of the Apex code.
Sample Apex Code
List conlist = [Select Name from Contact where AccountId != null]; for(Contact con : conlist)\{ con.title = ‘Dr’; } if (conlist.size()>0)\{ update conlist; system.debug(‘—-Success, ‘+conlist.size()+’ contact records updated—-‘); }
Formatting
‘\’ should be added immediately before ‘{‘ whenever you run in Apex Execute, as demonstrated in lines 3 and 7 of the sample above. This is necessary because ‘{‘ in Provar are generally used to define variables.
- General information
- Licensing Provar
- Provar trial guide and extensions
- Using Provar
- API testing
- Behavior-driven development
- Creating and importing projects
- Creating test cases
- Custom table mapping
- Functions
- Debugging tests
- Defining a namespace prefix on a connection
- Defining proxy settings
- Environment management
- Exporting test cases into a PDF
- Exporting test projects
- Managing test steps
- Namespace org testing
- Provar desktop
- Provar Test Builder
- Refresh and Recompile
- Reload Org Cache
- Reporting
- Running tests
- Searching Provar with find usages
- Secrets management and encryption
- Setup and teardown test cases
- Tags and Service Level Agreements (SLAs)
- Test cycles
- Test plans
- Testing browser options
- Tooltip testing
- Using the Test Palette
- Using custom APIs
- Callable tests
- Data-driven testing
- Page objects
- Block locator strategies
- Introduction to XPaths
- Creating an XPath
- JavaScript locator support
- Label locator strategies
- Maintaining page objects
- Mapping non-Salesforce fields
- Page object operations
- ProvarX™
- Refresh and reselect field locators in Test Builder
- Using Java method annotations for custom objects
- Applications testing
- DevOps
- Introduction to test scheduling
- Apache Ant
- Configuration for sending emails via the Provar Command Line Interface (CLI)
- Continuous integration
- AutoRABIT
- Azure DevOps
- Running a Provar CI task in Azure DevOps
- Configuring the Provar secrets password in Microsoft Azure Pipelines
- Parallel execution in Microsoft Azure Pipelines using multiple build.xml files
- Parallel execution in Microsoft Azure Pipelines using targets
- Parallel execution in Microsoft Azure Pipelines using Test Plans
- Bitbucket Pipelines
- CircleCI
- Copado
- Docker
- Flosum
- Gearset
- GitHub Actions
- Running a Provar CI task in GitHub Actions
- Remote Trigger in GitHub Actions
- Parameterization using Environment Variables in GitHub Actions
- Parallel Execution in GitHub Actions using multiple build.xml files
- Parallel Execution in GitHub Actions using Targets
- Parallel Execution in GitHub Actions using Test Plan
- Parallel Execution in GitHub Actions using Job Matrix
- GitLab CI
- Jenkins
- Travis CI
- Parallel Execution
- Running Provar on Linux
- Reporting
- Salesforce DX
- Git
- Team foundation server
- Version control
- Zephyr Cloud and Server
- Salesforce testing
- Adding a Salesforce connection
- Assert Page Error Messages on Add/Edit Product
- Dynamic Forms
- Internationalization support
- List and table testing
- Salesforce Release Updates
- Salesforce Lightning Testing
- Salesforce Lightning Web Component (LWC) locator support
- Salesforce console testing
- Visualforce Testing
- Testing best practices
- Troubleshooting
- Release notes