You need to sign in to do that
Don't have an account?
Error from Eclipse when Attempting to save a test case.
Severity and Description Path Resource Location Creation Time Id Save error: Unable to perform save on all files: An unexpected error has occurred. Please try again, or check the log file for details. SFDC-Production/src/classes Tester.cls line 1 1258989848164 3832
Checking the Eclipse log I see this:
!ENTRY com.salesforce.ide.core 2 0 2009-11-23 07:24:08.117 !MESSAGE WARN [2009-11-23 07:24:08,101] (ProjectService.java:handleDeployResult:1892) - Save failed! !ENTRY com.salesforce.ide.core 2 0 2009-11-23 07:24:08.132 !MESSAGE WARN [2009-11-23 07:24:08,132] (ProjectService.java:handleRetrieveResult:2037) - Nothing to save to project - retrieve result is empty !ENTRY com.salesforce.ide.core 4 0 2009-11-23 07:24:08.148 !MESSAGE ERROR [2009-11-23 07:24:08,148] (BuilderController.java:handleException:134) - Unable to perform save on all files. !STACK 0 java.lang.NullPointerException at com.salesforce.ide.core.services.ProjectService.setRunTestFailureMarker(ProjectService.java:2303) at com.salesforce.ide.core.services.ProjectService.handleRunTestMessages(ProjectService.java:2278) at com.salesforce.ide.core.services.ProjectService.handleRunTestResult(ProjectService.java:2198) at com.salesforce.ide.core.services.ProjectService.handleDeployResult(ProjectService.java:1904) at com.salesforce.ide.core.project.BuilderController.handleSaves(BuilderController.java:118) at com.salesforce.ide.core.project.BuilderController.build(BuilderController.java:95) at com.salesforce.ide.core.project.BuilderController.build(BuilderController.java:75) at com.salesforce.ide.core.project.OnlineBuilder.incrementalBuild(OnlineBuilder.java:79) at com.salesforce.ide.core.project.OnlineBuilder.build(OnlineBuilder.java:49) at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:624) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:166) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:197) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:246) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:249) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:302) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:334) at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:137) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
This Test apex class looks like this:
static testMethod void testCPcontrollerApex() { Contact con = [select Id, Name from Contact where Id = '0035000000VnUZk']; User u = [select Id, ContactId from User where ContactId = :con.Id]; u = [SELECT id, UserName, CompanyName, Email FROM User WHERE Id=:u.id]; System.assertEquals('Tom.Sample@company.com',u.UserName);// Test to make sure the case was inserted. System.assertEquals('Tom.Sample@company.com',u.Email); PageReference pageRef = Page.CP_Welcome_Message2; // Get the VF Page that uses this controller. ApexPages.currentPage().getParameters().put('Id', u.id); //Do this first so controller has a user Id to work with. CPcontroller controller = new CPcontroller(); controller = new CPcontroller(); // Instantiate the new controller.. controller.getUser(); controller.getContact(); }
This same test class works fine in my sandbox environment. I can save other apex class changes fine, only this piece of code fails to save. Any ideas what the problem is?
Regards,
Hello Chidev... What I found it to mean was there was no result retrieved by the query from the User Table. I found it strange that I didn't run into this error on the sandbox system only on the production test suite. I would have expected the trigger not to have executed and the % code coverage to be 0%... not a error on the save from Eclipse.
So, I would insure that the record you are query for actually exists in the object.
Hope this helps.
Regards,
All Answers
Hello Chidev... What I found it to mean was there was no result retrieved by the query from the User Table. I found it strange that I didn't run into this error on the sandbox system only on the production test suite. I would have expected the trigger not to have executed and the % code coverage to be 0%... not a error on the save from Eclipse.
So, I would insure that the record you are query for actually exists in the object.
Hope this helps.
Regards,
When you save to a production organization from the IDE, it's the same as a deploy. All your Apex test methods are executed to ensure you haven't caused a regression (test failure) or reduced your code coverage.
The IDE should not be experiencing a NullPointerException; that looks like some kind of bug that we'll have to investigate.
But the best way to do this is NOT to create a Force.com project directly against your production organization. Instead, once you have it working in your sandbox, use the Deploy to Server wizard (right-click on the "src" folder and choose Force.com > Deploy to Server) to deploy your changes from your sandbox project to your production organization. Any test failures or other deploy errors will be displayed in the results when the wizard concludes.
Alternatively, you also can use the Cloud Deploy / Change Sets feature in Setup (under App Setup | Deploy) to migrate your changes from sandbox to production.
Jon
salesforce.com Product Manager