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 is generally used to define variables.
- Provar Automation
- Installing Provar Automation
- Updating Provar Automation
- Using Provar Automation
- 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
- Override auto-retry for Test Step
- Managing test steps
- Namespace org testing
- NitroX
- Provar desktop
- Provar Test Builder
- Refresh and Recompile
- Reintroduction of CLI license Check
- 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 Automation Command Line Interface
- Continuous integration
- AutoRABIT Salesforce DevOps in Provar Test
- Azure DevOps
- Running a Provar CI Task in Azure DevOps Pipelines
- Configuring the Automation 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 DevOps CI/CD
- GitHub Actions
- Integrating GitHub Actions CI to Run Automation CI Task
- 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 Continuous Integration
- Travis CI
- Jenkins
- Execution Environment Security Configuration
- Provar Jenkins Plugin
- Parallel Execution
- Running Provar on Linux
- Reporting
- Salesforce DX
- Git
- Team Foundation Server
- Version control
- Provar Automation trial guide and extensions
- Salesforce Testing
- Provar Manager
- Best Practices
- Troubleshooting
- Release Notes