cumulusci.tasks.apex package

Submodules

class cumulusci.tasks.apex.anon.AnonymousApexTask(project_config, task_config, org_config=None, flow=None, name=None, stepnum=None, **kwargs)[source]

Bases: cumulusci.tasks.salesforce.BaseSalesforceApiTask.BaseSalesforceApiTask

Executes anonymous apex from a file or string.

task_docs = '\n Use the `apex` option to run a string of anonymous Apex.\n Use the `path` option to run anonymous Apex from a file.\n Or use both to concatenate the string to the file contents.\n '
task_options = {'apex': {'description': 'A string of Apex to run (after the file, if specified).', 'required': False}, 'managed': {'description': "If True, will insert the project's namespace prefix. Defaults to False or no namespace.", 'required': False}, 'namespaced': {'description': 'If True, the tokens %%%NAMESPACED_RT%%% and %%%namespaced%%% will get replaced with the namespace prefix for Record Types.', 'required': False}, 'param1': {'description': 'Parameter to pass to the Apex. Use as %%%PARAM_1%%% in the Apex code.Defaults to an empty value.', 'required': False}, 'param2': {'description': 'Parameter to pass to the Apex. Use as %%%PARAM_2%%% in the Apex code.Defaults to an empty value.', 'required': False}, 'path': {'description': 'The path to an Apex file to run.', 'required': False}}

a task for waiting on a Batch Apex job to complete

class cumulusci.tasks.apex.batch.BatchApexWait(project_config, task_config, org_config=None, flow=None, name=None, stepnum=None, **kwargs)[source]

Bases: cumulusci.tasks.salesforce.BaseSalesforceApiTask.BaseSalesforceApiTask

BatchApexWait polls an org until the latest batch job for an apex class completes or fails.

elapsed_time(subjobs: Sequence[dict])[source]

returns the time (in seconds) that the subjobs took, if complete

failed_batches(subjobs: Sequence[dict])[source]
name = 'BatchApexWait'
original_created_date = None
summarize_subjobs(subjobs: Sequence[dict])[source]
task_options = {'class_name': {'description': 'Name of the Apex class to wait for.', 'required': True}, 'poll_interval': {'description': 'Seconds to wait before polling for batch job completion. Defaults to 10 seconds.'}}

CumulusCI Tasks for running Apex Tests

class cumulusci.tasks.apex.testrunner.RunApexTests(project_config, task_config, org_config=None, flow=None, name=None, stepnum=None, **kwargs)[source]

Bases: cumulusci.tasks.salesforce.BaseSalesforceApiTask.BaseSalesforceApiTask

Task to run Apex tests with the Tooling API and report results.

This task optionally supports retrying unit tests that fail due to transitory issues or concurrency-related row locks. To enable retries, add ones or more regular expressions to the list option retry_failures.

When a test run fails, if all of the failures’ error messages or stack traces match one of these regular expressions, each failed test will be retried by itself. This is often useful when running Apex tests in parallel; row locks may automatically be retried. Note that retries are supported whether or not the org has parallel Apex testing enabled.

The retry_always option modifies this behavior: if a test run fails and any (not all) of the failures match the specified regular expressions, all of the failed tests will be retried in serial. This is helpful when underlying row locking errors are masked by custom exceptions.

A useful base configuration for projects wishing to use retries is

```yaml
retry_failures:
  • “unable to obtain exclusive access to this record”
  • “UNABLE_TO_LOCK_ROW”
  • “connection was cancelled here”

retry_always: True

```

Some projects’ unit tests produce so many concurrency errors that it’s faster to execute the entire run in serial mode than to use retries. Serial and parallel mode are configured in the scratch org definition file.

api_version = '38.0'
name = 'RunApexTests'
task_options = {'json_output': {'description': 'File name for json output. Defaults to test_results.json'}, 'junit_output': {'description': 'File name for JUnit output. Defaults to test_results.xml'}, 'managed': {'description': 'If True, search for tests in the namespace only. Defaults to False'}, 'namespace': {'description': 'Salesforce project namespace. Defaults to project__package__namespace'}, 'poll_interval': {'description': 'Seconds to wait between polling for Apex test results.'}, 'retry_always': {'description': 'By default, all failures must match retry_failures to perform a retry. Set retry_always to True to retry all failed tests if any failure matches.'}, 'retry_failures': {'description': 'A list of regular expression patterns to match against test failures. If failures match, the failing tests are retried in serial mode.'}, 'test_name_exclude': {'description': 'Query to find Apex test classes to exclude ("%" is wildcard). Defaults to project__test__name_exclude from project config. Comma-separated list for multiple patterns.'}, 'test_name_match': {'description': 'Pattern to find Apex test classes to run ("%" is wildcard). Defaults to project__test__name_match from project config. Comma-separated list for multiple patterns.', 'required': True}}

Module contents