Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have written a test class for a trigger in the ide. It saves just fine, with no errors but only locally. Why won't it save to the server?

private with sharing class UpdateContact {
    static testMethod void myUnitTest() {

Rating__c testRating = [select id,name from rating__c where Contact__c='003a000001bEJdb'];

update testRating;

Rating__c updatedRating = [SELECT rating__c FROM Rating__C Where Contact__c='003a000001bEJdb'];

share|improve this question
if there are no errors, try "save to server". Or verify network (proxy) settings. – Sai Jan 15 '13 at 20:22
The 'Problems' section at the bottom should tell you the reason for the error. Most likely compilation error. – techtrekker Jan 15 '13 at 20:24
Would the fact that there are other triggers that have errors keep this one from saving to the server? – Merry Jan 15 '13 at 20:52

It most likely won't save to the server because of errors in another class as the syntax looks like it should save, however, you will most likely have failures when you attempt to run this unit test anyway. The main reason for that is the fact that you are attempting to access a record already in the system. That is a very poor practice in general because:

  1. You never want to depend on records being in the system for a unit test. These tests would fail in any system that doesn't have this record in the system.

  2. You won't even be able to access this data the way your class is set up currently with any API version after 24.0. For this to even work, ou would need to set the class up to access the data:


Without knowing what your trigger does, I would also be wary of your assert statement. You are asserting that the value you set on the record and updated is the same. Unless you are validating that a trigger did NOT update that value, that test isn't very valid and may not provide you with much. Remember, just because a piece of code can provide you code coverage, you still want to strive for valid tests to fully verify your code is functioning properly.

Finally, you should be able to see what the problem with your class is by viewing the Problems perspective of your IDE. In the Menu bar it is under Window > Show View > Problems.

share|improve this answer

If you are attempting to save multiple files at once then an error in any of the files will cause the entire operation to fail.

To see the errors for just that class right click on it and go to -> "save to server" it should only fail to save if there are errors with that class.

Note that if you are saving to production it will also run all the unit tests and fail to save if there are any errors.

share|improve this answer

Are other things saving to the server when you edit them? If not, then the problem may be with Eclipse.

Try working within the app and creating/saving the class. Then note any error messages that come up.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.