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

Tests pass in the sandbox but fail in deployment - need help.

I have complete test success with 86% code coverage in the sandbox, but they fail in deployment.  See my post below entitled "tests failing". Any ideas anyone?




Typically the reasons for this are :


1. If you are depending on data already setup in the org for yout test methods, the data in your destination org might not exists and hence your tests might be failing

2. If you are doing System.runAs() in your test methods, the profile permissions might not be the same as sandbox and hence might lead to failures.


I would look at the deployment logs to determine what is failing investigate a little further.


Thanks for your response.  There is very little data (only a few records) in this particular Sandbox, the main system has much more data.  So I think it would be much more likely to fail in the Sandbox. 


I checked the run as, but everything seemed ok. 


The logs show that one record is failing to insert.  I corrected the problem and added the record, but the system failed again, this time on the second row (even though theoretically there was no second row).  When I added yet another record, it failed on the third row. 


Any ideas?