Salesforce metadata management tool
The tool is currently only capable of verifying a deployment package by deploying it with [checkOnly] (https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_deploy.htm) parameter set to true and running a subset of tests. This is done to speed up testing step in the CI workflow (run a subset of tests instead of all tests).
The tool uses [sfdclib Python library] (https://github.com/rbauction/sfdclib) to manipulate Salesforce metadata.
Names of the Apex classes that get tested are extracted from the deployment package.
- If deployment package contains a test class it will be added to the list of classes to test.
- For non-test classes the tool will build a dependency map for all test classes it can find in the source directory and then check whether any non-test classes from the deployment package are referenced by test classes. If there is a match the corresponding test class(es) will be added to the list of classes to test.
- RealClass
- UnrealClass
- TestableClassTest
- RealClass
- RealClassTest (references RealClass)
- UnrealClass
- TestableClass
- TestableClassTest (references TestableClass)
- RealClassTest
- TestableClassTest
Install Python v3.4, PyYAML package, install [sfdclib Python library] (https://github.com/rbauction/sfdclib) and clone this repository.
pip install PyYAML
pip install sfdclib
git clone https://github.com/rbauction/metamate.git
Download executable file from [releases] (https://github.com/rbauction/metamate/releases) tab or follow the instruction above.
Install PyInstaller and then run the following command:
pyinstaller metamate.spec
Resulting exe file can be found in dist directory.
metamate.py deploy [-h] --username USERNAME --password PASSWORD [--token TOKEN]
--deploy-zip DEPLOY_ZIP --source-dir SOURCE_DIR
[--sandbox] [--check-only] [--use-cache] [--version VERSION]
or
metamate.py clear-cache --username USERNAME
# Validate deployment package (Windows, Linux, UNIX and Mac OS)
python metamate.py deploy --check-only --sandbox --username [email protected] --password Password --deploy-zip ../deploy.zip
# Deploy using default Metadata API version (Windows, Linux, UNIX and Mac OS)
python metamate.py deploy --sandbox --username [email protected] --password Password --deploy-zip ../deploy.zip
# Specify Metadata API version and token (Windows, Linux, UNIX and Mac OS)
python metamate.py deploy --sandbox --version 37.0 --username [email protected] --password Password --token TOKEN --deploy-zip ../deploy.zip
# Deploy using default Metadata API version (Windows only)
metamate.exe deploy --sandbox --username [email protected] --password Password --deploy-zip ..\deploy.zip
# Compile all test classes to resolve dependencies
python metamate.py deploy --check-only --test-level RunSpecifiedTests --sandbox --username [email protected] --password Password --deploy-zip ../deploy.zip --source-dir ../src
# Use local cache and compile only changed test classes (cache will be populated for each sandbox first time the tool is run)
python metamate.py deploy --use-cache --check-only --test-level RunSpecifiedTests --sandbox --username [email protected] --password Password --deploy-zip ../deploy.zip --source-dir ../src
python metamate.py clear-cache --username [email protected]