+ Start a Discussion

Test method Failures in Managed Packages

Shouldn't 'test methods' inside of managed packages not run any triggers in other installed managed packages?


It's impossible for managed package producers to predict the triggers that will run after a record is insert in their test methods?


Example (abbreviated):


static void testRemoteActions(){
   Campaign testCampaign = new Campaign(name='Test Campaign');
   insert testCampaign;
   Controller controller = new Controller();
   if(controller.isChatterEnabled){controller.updateChatterStatus('Hello world!');}

// check chatter enabled
class controller{
    public Boolean isChatterEnabled{get; set;}     
    public void checkChatterEnabled() 
            this.isChatterEnabled = true; 
            this.isChatterEnabled = false;      



Trigger Exception: 

System.DmlException: Update failed. First exception on row 0 with id: 000000000; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, UserTrigger; execution of AfterUpdate caused by: System.QueryException: List has no rows for assignment...'

Note: I'm not inserting a user and using System.runas(u) { } in my test method because I don't know all the required profiles/user requirement triggers in the destination org.


Am I just thinking about it wrong? 





Can u paste the debug logs when this error is occuring....It looks like it can be fixed


It's possible, going to try one more solution (and than going to attempt to get the debug log)


The question goes fundamentally goes to the implementation: should I have to change my test methods so they never fail, reguardless?


You can't migrate sandbox -> production with test method failures as the failures in the installed package result in the migration tool failing to move any other code.


Some admins don't want to have to uninstall my package from their sandbox org just to migrate the rest of their code to production.