function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MCP1MCP1 

Writing Test Classes for Deployment

Hi there, I have a few questions about deploying the Apex classes and I'm hoping you'll be able to enlighten me.

 

 

I noticed that I can't test the code deployment when migrating from Development to Sandbox. The deployment tool in IDE does not check the code coverage when deploying from Dev to Sandbox. Is there a way to test deployment with code coverage test before the actual deployment to production? I know we can run the test classes independently but I would like to see how deployment with code coverage test would go before doing it in production.

 

 

In some of my test classes I had to reference an existing data created from a custom object. Dynamically adding the data via the test class will exceed the limit of 100 SOQL since the the application consists of different approvals and processes.

 

If my said test class has the hardcoded ID of an existing data on the sandbox environment, would I be able to deploy it to production or would the deployment tool look for that data in production?

 

 

Thanks in advance for the help.

 

 

richardvrichardv

You could use the "Validate Deployment" button in Eclipse as part of the "Deploy to Server" wizard in order to simulate a deployment to production.  The downside is its a little scary to do that because you might accidentally hit the Next button instead of the Validate Deployment - which would of course trigger a real deployment to production.  I wish there was a way to invoke the mock deployment without the chance of easily invoking the real deployment.  If anyone knows how to do that, please share.

 

-Richard Vanhook 

JonPJonP

I've posted this as an idea on IdeaExchange:

 

"Staging Sandbox" Enforcing Production Deployment Rules

 

You can vote if you agree (or disagree), and if it's missing anything please post in the comments.

 

Thanks,

Jon

MCP1MCP1
Thanks Richard and Jon, I really appreciate it.
MCP1MCP1

Hi again, would you know if there's a way to call a test class from within another test class?

I'm having difficulty testing all my apex classes because of the 100 SOQL limitation.

 

Thanks so much!

 

Jeremy-KraybillJeremy-Kraybill

The governor limits apply per test method - not test class - so typically if you are hitting governor limits in your test methods, the solution is to break up your test across several test methods.

 

HTH

 

Jeremy Kraybill

Austin, TX

MCP1MCP1
Thanks Jeremy!