This plugin is used to manipulate logic statements in source code then run tests against those manipulations to see if your tests are able to validate the logic differences.
Currently supports Apex Classes only
For Apex, this plugin does not use your local source code and does not need to be in a project directory. It reads code from the target org ONLY. This is because it is using that org as an execution environment, the local source isn't particularly helpful. If you're evaluating changed code, push it to the org before running this tool.
sf plugins install sf-warp
(depends on native compiled modules, tree-sitter and tree-sitter-sfapex, may need functional compilation tools on your system to install)
Please report any issues at https://github.com/aheber/sf-warp/issues
To build the plugin locally, make sure to have yarn installed and run the following commands:
# Clone the repository
git clone git@github.com:aheber/sf-warp
# Install the dependencies and compile
yarn && yarn build
To use your plugin, run using the local ./bin/dev
or ./bin/dev.cmd
file.
# Run using local run file.
./bin/dev warp apex -c [classname]
There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
# Link your plugin to the sf cli
sf plugins link .
# To verify
sf plugins
sf warp apex
Warp an Apex class in the target org, run tests to see if they notice.
USAGE
$ sf warp apex [--json] [-e <value>] [-c <value>] [-t <value>] [-o <value>] [-p <value>] [-a] [-v
none|minimal|details|full]
FLAGS
-a, --analyze-only Don't modify the Apex, only report possible changes.
-c, --class=<value> Class name to warp.
-e, --username=<value> [default: test-pxjwqols06it@example.com]
-o, --timeout=<value> [default: 120] Maximum seconds for each deployment or test execution
-p, --test-class-match-pattern=<value>... [default:
Test{classname},Test_{classname},{classname}_Test,{classname}Test]
Fallback pattern to find supporting test classes.
-t, --test-class=<value>... Class name to use in testing.
-v, --verbosity=(none|minimal|details|full) [default: minimal] Set the output verbosity to control the text volume
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Warp an Apex class in the target org, run tests to see if they notice.
For one or many Apex classes, warp one small aspect at a time and run tests against that variation.
If your tests notice the change and fail that is good, your tests proved that they are validating logic. If the test
still passes then your tests didn't care about the logic change. That might indicate a need for a better test, or it
might indicate that the change would never matter and is a false-positive.
EXAMPLES
Execute against a class named "Utils"
$ sf warp apex --class Utils
Increase verbosity to see what changes are being made
$ sf warp apex --class Utils --verbosity details
Specificy multiple test classes that should be used for evaluation
$ sf warp apex --class Utils --test-class Utils_Test --test-class TestForUtils
FLAG DESCRIPTIONS
-p, --test-class-match-pattern=<value>... Fallback pattern to find supporting test classes.
Specify a test pattern that will be used against available class names existing in the org. Matches that are test
classes will be used to evaluate mutations.
Available replacements are:
- className - The name of the Class under test
examples: `Test{className}`, `{className}_Test`, `{className}Test`
NOTE: Only used if a specific test class was not specified.