+ Start a Discussion

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.




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 


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 Richard and Jon, I really appreciate it.

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!



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.




Jeremy Kraybill

Austin, TX

Thanks Jeremy!