- Salesforce ant migration tool how to#
- Salesforce ant migration tool upgrade#
- Salesforce ant migration tool code#
NOTE: The above was not always the case, i cannot recall when, but there was a time it behaved like the compileAndTest request above. If any of these tests fail when the rollbackOnError parameter is set to true, the deployment is rolled back and no changes will be made to your organization. For deployment to a production organization, all tests, except for those that originate from installed managed packages, are automatically run regardless of this argument. If set to true, all tests are run after deploy.
In contrast the runAllTests="true" on the sf:deploy target is explicitly documented as to not run managed classes tests. Also, if you execute compileAndTest() in a production organization, this property is ignored, and all unit tests defined for the organization are run. Do not use this property if you specify allTests as true. If specified, the namespace that contains the unit tests to be run. In production environments its basically ignored as per the documentation for the underlying Apex SOAP API the Ant task uses here. I was also surprised to learn that its not formally part of the Metadata API, commonly used by the Ant tools under the covers.Īnyway, I've tracked down what seems to be at least a documented explanation regarding the namespace="Default" support. It is strange that the sf:compileAndTest Ant task is no longer (since i am sure i've seen it in the past) documented either in the official Migration Toolkit docs or the readme.html you get with the download.
Salesforce ant migration tool code#
This gives us incremental updates as the tests are running and allows the deployment of the source files to succeed in a separate ant target (not described below) while the tests may fail (insufficient code coverage, failing assertions, etc.) This is tested against v30 of the ant migration tool Īlternatively, we've actually used a version of 'deploy' that does a no-op deploy (the package.xml in the 'ant' directory is empty except for the element. This was the workaround for pre-Summer '15 for posterity:īecause I killed off the better part of a day hacking around in ant to accomplish the workaround suggested, I wanted to publish a working example In my case, the test classes are prefixed with "Test_" but you can fool around with the fileset as necessary This test level is the default for production deployments that include Apex classes or triggers. RunLocalTests-All tests in your organization are run, except the ones that originate from installed managed packages.
In particular, to run a subset of tests in a deployment, set testLevel to the RunSpecifiedTests value and specify the tests to run in the runTests option. For a description of all test levels, see test levels for the deploy() call. You can choose which tests to run in a deployment by setting the desired test level.
Salesforce ant migration tool upgrade#
If you upgrade your ant-salesforce.jar to one that supports API version 34, you can now pass a " testLevel=RunLocalTests" attribute to sf:deploy like so: Īs part of this change, the runAllTests deployment option is now replaced with testLevel. Request Status: InProgress (500/689) - Running Test: DB_UnitTests.test_PostInstallĮdit: Summer '15 made this "all better". Request Status: InProgress (493/689) - Running Test: DB_UnitTests.test_Db2Upgrade Request Status: InProgress (487/689) - Running Test: DB_UnitTests.test_DB_KeyBuilder_useBatchApexKeyBuilder First exception on row 0 first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter valid country CRMfusionDBR101.DB_UnitTests.testRebuildKeys_MultipleLeads_MultiBatch_SameHash_DupeFirstBatch - System.DmlException: Insert failed. Īs outcome of this run it gives me these test class failures which are from managed packages like CRMFusion's DupeBlocker and others Test Failures: I tried with the sample build.xml and the latest Migration toolkit. I checked further the runAllTests=True and seems to run all test classes also the ones from a managed package.
Salesforce ant migration tool how to#
There is a post here Get Status Updates When Running Tests with ANT Migration ToolĪnd here How to run tests in the default namespace in a sandbox using Antīut both don't really answer the question if the actually works in ant or not. Then i found 2 other posts that are talking about the sf:compileAndTest method in ant where you can specify but this doesn't seem to work either.
Now i searched on the documentation of the tool and i only find the runAllTests = true, which runs all tests including managed package code. I would like to configure the ant migration tool so that only test classes are run that we own so no managed package classes.