[SalesForce] System.DmlException: Process failed. First exception on row 0; first error: MANAGER_NOT_DEFINED, Manager undefined.: []

        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];

Best Answer

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....
}