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
Angel Luis Sanz AceitunoAngel Luis Sanz Aceituno 

Errors in Apex test for npsp and marketing cloud connect

Dear all,

I´ve installed in the customer´s Sandbox NPSP and Marketing Cloud connect and when I´m performing the APEX Test during the validation of the change sets to Production, the system is giving 1012 fails of 1842, how is that even possible with a Salesforce managed software?
I´m Junior in this matter and not a developer, I don´t know how many errors in the APEX test the customer had before and couldn´t check in their production either. But we need help in this matter because this is Salesforce managed code and we couldn´t access it to even see what is giving the error or change the test conditions. 

I have removed my APEX code since I used it only for a minor thing, but... even with the code disabled (trigger and class), the errors from the managed packages are there and I want to give our customer the best possible assistance.

I know that A LOT of the errors are from Validation rules and required fields (more than half of them), but ... how do I solve them if I´m not able to modify the test? 

And what about the other kind of errors, where do they come? Did you have similar problems? 

The list of errors is huge, so I will leave here just a glimpse of some:
 
Test_abTestDetailControl constructorTest System.QueryException: List has no rows for assignment to SObject Stack Trace: Class.et4ae5.TestUtility.createUser: line 303, column 1 Class.et4ae5.Test_abTestDetailControl.constructorTest: line 49, column 1 

Test_abTestDetailControl testCancel System.QueryException: List has no rows for assignment to SObject Stack Trace: Class.et4ae5.TestUtility.createUser: line 303, column 1 Class.et4ae5.Test_abTestDetailControl.getabTestDetailControl: line 10, column 1 

Class.et4ae5.Test_abTestDetailControl.testCancel: line 78, column 1 Test_businessUnitListControl test_save System.QueryException: List has no rows for assignment to SObject Stack Trace: Class.et4ae5.Test_businessUnitListControl.setupData: line 14, column 1 

Class.et4ae5.Test_businessUnitListControl.test_save: line 545, column 1 Test_businessUnitListControl test_selectAll System.QueryException: List has no rows for assignment to SObject Stack Trace: Class.et4ae5.Test_businessUnitListControl.setupData: line 14, column 1 

Class.et4ae5.Test_businessUnitListControl.test_selectAll: line 459, column 1 ACCT_IndividualAccounts_TEST attachToIndividualAccount System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, El teléfono, el correo electrónico o el móvil deben estar cumplimentados.: [] Stack Trace: Class.npsp.ACCT_IndividualAccounts_TEST.attachToProcessor: line 521, column 1 Class.npsp.ACCT_IndividualAccounts_TEST.attachToIndividualAccount: line 500, column 1 ACCT_IndividualAccounts_TEST contactAddedToExistingHHAccount System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, El teléfono, el correo electrónico o el móvil deben estar cumplimentados.: [] Stack Trace: 

Class.npsp.ACCT_IndividualAccounts_TEST.contactAddedToExistingProcessor: line 675, column 1 

Class.npsp.ACCT_IndividualAccounts_TEST.contactAddedToExistingHHAccount: line 659, column 1 BDI_DataImport_TEST2 ManyDIMultiContactMatchRules5 System.AssertException: Assertion Failed: Expected: 3, Actual: 0 Stack Trace: 

Class.npsp.BDI_DataImport_TEST2.ManyDIMultiContactMatchRules: line 1167, column 1 Class.npsp.BDI_DataImport_TEST2.ManyDIMultiContactMatchRules5: line 1125, column 1 BDI_DataImport_TEST2 ManyDIMultiContactMatchRules6 System.AssertException: Assertion Failed: Expected: 3, Actual: 0 Stack Trace: 

Class.npsp.BDI_DataImport_TEST2.ManyDIMultiContactMatchRules: line 1167, column 1 Class.npsp.BDI_DataImport_TEST2.ManyDIMultiContactMatchRules6: line 1129, column 1 UTIL_UnitTestData_TEST testCreateNewUserWithDefaultRole System.QueryException: List has no rows for assignment to SObject Stack Trace: 

Class.npsp.UTIL_UnitTestData_TEST.createNewUserWithRoleForTests: line 355, column 1 Class.npsp.UTIL_UnitTestData_TEST.createNewUserForTests: line 409, column 1 Class.npsp.UTIL_UnitTestData_TEST.testCreateNewUserWithDefaultRole: line 468, column 1 UTIL_UnitTestData_TEST testCreateNewUserWithRandomRole System.QueryException: List has no rows for assignment to SObject Stack Trace: 

Class.npsp.UTIL_UnitTestData_TEST.createNewUserWithRoleForTests: line 355, column 1 Class.npsp.UTIL_UnitTestData_TEST.testCreateNewUserWithRandomRole: line 485, column 1

Thank you very much!

PS: I can´t open a Salesforce case since It doesn´t allow me from a Partner or standard user account. 
 
Best Answer chosen by Angel Luis Sanz Aceituno
_Prasu__Prasu_
Yes that is fine. For this very specific case Salesforce has provide test method execution selection. You can refer following link for more information.

https://releasenotes.docs.salesforce.com/en-us/winter16/release-notes/rn_deployment_change_sets_test_levels.htm
https://salesforce.stackexchange.com/questions/21507/how-to-handle-installed-managed-packages-failing-tests

All Answers

_Prasu__Prasu_
You can ignore the error messages which are given by the Managed Package test classes. They shouldn't stop you from deploying the Change sets. While validating the changeset you can execute test classes local to your org to avoid this problem. 
Angel Luis Sanz AceitunoAngel Luis Sanz Aceituno
Dear _Prasu_,
Is that right? Because the change sets testing took every test in the ORG so it ended with 1012 test of 1840 failing....
And of course give a failure in the validation of the process.

Thanks!
_Prasu__Prasu_
Yes that is fine. For this very specific case Salesforce has provide test method execution selection. You can refer following link for more information.

https://releasenotes.docs.salesforce.com/en-us/winter16/release-notes/rn_deployment_change_sets_test_levels.htm
https://salesforce.stackexchange.com/questions/21507/how-to-handle-installed-managed-packages-failing-tests
This was selected as the best answer
Angel Luis Sanz AceitunoAngel Luis Sanz Aceituno
Thank you _Prasu_, I knew the existence of it and tried the default and the complete, but didn´t know the complete extension of that option, because was troubled about the managed package. Now I do, thank you very much! :)