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
Jordan@BracketLabsJordan@BracketLabs 

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):

 

@isTest
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() 
    {
        if(User.SobjectType.getDescribe().feedEnabled)
            this.isChatterEnabled = true; 
        else
            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...'
Trigger.UserTrigger

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? 

 

 

 

steve456steve456

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

Jordan@BracketLabsJordan@BracketLabs

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.