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
tbfan6789tbfan6789 

Validation errors in Change Sets

We have our Admin trying to deploy permission sets and new fields on the Activity object via a change set. Every time he validates he runs into validation errors in a couple of our test classes. However, when I run the unit tests on the classes in Salesforce, I receive no errors. Plus, when we push that same change set to one of our development environments that has the same classes as production, we do not receive any errors in validation.

 

Has anyone seen this before? Does anyone know of a solution. Eclipse is a workaround, but we would like to fix this as soon as possible.

arizonaarizona

Can you screen capture the results of the validation and post them.

tbfan6789tbfan6789

ChangeSet Screenshot

tbfan6789tbfan6789

Sorry, I'm having a hard time posting a screen shot.

tbfan6789tbfan6789
TestAccountModel.testGetContacts()Class1521Failure Message: "System.AssertException: Assertion Failed: Expected: 0, Actual: 1", Failure Stack Trace: "Class.TestAccountModel.testGetContacts: line 152, column 1"
TestCaseServices.testCloseAndUpdateChildCases()Class458 Failure Message: "System.LimitException: Too many SOQL queries: 101", Failure Stack Trace: "Class.CaseServices.updateParentCaseAttachmentNotes: line 458, column 1 Trigger.CaseAttachmentTrigger: line 43, column 1"
TestOppAttachmentSearchController.TestAttachmentSearch_with_attach()Class221Failure Message: "System.NullPointerException: Attempt to de-reference a null object", Failure Stack Trace: "Class.TestOppAttachmentSearchController.TestAttachmentSearch_with_attach: line 22, column 1"
TestOppAttachmentSearchController.TestAttachmentSearch_without_attach()Class741Failure Message: "System.NullPointerException: Attempt to de-reference a null object", Failure Stack Trace: "Class.TestOppAttachmentSearchController.TestAttachmentSearch_without_attach: line 74, column 1"

 

 

Here are the errors we're receiving. The odd one is the GetContacts method. The System Asset that is failing on is expecting a 1, but in the validation it's stating that assert is expecting a 0. The other methods do not fail when we run all tests in Production.

arizonaarizona

I do not have a good answer for you but whatever is being pushed is affecting the test class.

 

System.AssertException  means there is a System.AssertEquals in the test class that for some reason is getting different results due to what is being pushed to production. The System.assertEquals() takes two parameters.  It depends on the order for the expected actual.

 

It may be that the system administrator does not have the same rights as the developer that pushed the code the last time.  Perhaps a developer that has all admin rights tried to push it would work.

 

Nathan

tbfan6789tbfan6789

We were able to the change sets working again. I had to make some slight modifications to the test classes so it would pass the validation. I just find it odd that the test classes only error out for the change set user and not admin. For SOQL errors, I would expect erros to show up even as an Admin. Is there anyway to give access to a user with the change set profile to run all tests?

arizonaarizona

There is probably a sharing issue such that the record is not available to the change set user.

 

You can use system.runas method to test for this.

 

User u = some user

 

system.runas(u){

 

   Anything inside here is run as the user.

 

}