开发者

Salesforce.com deployment

开发者 https://www.devze.com 2023-02-26 19:24 出处:网络
We are currently working on a Salesforce.com custom APEX project that involves a lot ofapex classes, triggers and Visualforce pages. We also have numerous applications from AppExchange that are part o

We are currently working on a Salesforce.com custom APEX project that involves a lot of apex classes, triggers and Visualforce pages. We also have numerous applications from AppExchange that are part of the system.

We develop all the Apex Classes, Visualforce pages, etc in test environment and then deploy it to the live environment using Eclipse IDE. What happens is that every time we deploy changes to the live environment, all the test methods of all the classes (including those from AppExchange Apps) seems to be executing. So deployment of a simple change could end up taking couple of minutes.

Is there a way in apex to "package" classes by namespace or something like that so that when we try to开发者_高级运维 deploy a change, only the test methods relevant to that package are executed. If something like that exists, our deployment can happen much faster.


Unfortunately no, there is no partial testing for deployment of apex code, every change, no matter how minute or self-contained triggers a full test run. This among other things enforces code metrics (minimum total code coverage for instance)

IMHO, this is proving to be a two-sided coin when it comes to enforcing code reliability. When we started using apex all of our tests were very comprehensive performing actual testing of the code with lots of asserts and checks. Then we started having very very long deploy times so now our tests serve one and only function, satisfying minimum code coverage, and even with that simplification it takes almost 3 minutes to deploy anything and we only use 20% of our apex code allowance. IMHO2, Apex is way too slow of a coding platform to be enforcing this kind of testing. I cant even imagine how long the tests would run if we reach 50% allowance, not to mention any more.


This is possible but you'll need to learn about Apache Ant and have a look at the Force.com Migration Toolkit. You can then use a Build file to determine which files are deployed as well as which tests are run.

I'm busy writing a whitepaper that'll touch on this and other related development strategies... I'll post to my blog when it's done.


If we use the apache ant migration tool we have many options for deployment like deployCodeFailingTest which will skip the test classes and if you want to run only specific test classes please use : something similar to this in ur build.xml

<target name="deployCode">
`<sf:deploy`
username="${sf.username}"
password="${sf.password}"
serverurl="${sf.serverurl}"
deployroot="codepkg">
<runTest>SampleDeployClass</runTest>
</sf:deploy>
</target>

for detailed reference please use this link http://www.salesforce.com/us/developer/docs/daas/salesforce_migration_guide.pdf


I would recommend the following approach:

  1. Git as repository for all your sf code
  2. jenkins to deploy your code as CI/CD
  3. PMD as the static code analyser
  4. sfdx as the deployment method in jenkins for deployment.

Refer the trailhead link: https://trailhead.salesforce.com/users/strailhead/trailmixes/architect-dev-lifecycle-and-deployment

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号