0
        Opportunity opp = new Opportunity();
        opp.Account = acc;
        opp.OPP_closing_note__c = 'test';
        opp.Unit_Price__c = 10;
        opp.Type = 'Project';

        insert opp;

        System.debug('---->oppp--- '+opp);

        opportunity newOpp = [Select Id from opportunity where id = :opp.id];

1 Answer 1

0

Manager means the Manager(User) of record owner.

So in test class, First you have to assign manager to the user you have created.

Profile p = [SELECT Id FROM Profile WHERE Name = 'System Administrator'];

User mgr = new User(        
    //assign required field values
);    
INSERT mgr;

User u = new User(    
    //assign required field values
    ManagerId = mgr.Id;
);    
INSERT u; 

System.runAs(u) {
    //Write all other codes here....
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .