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
NaiveUserNaiveUser 

Apex test class for OpportunityPartner object

Hi,

I am trying to write a test class around OpportunityPartner object. This object being a read-only one, it does not allow me to insert/update test records in test class. Any Help!!!

souvik9086souvik9086

You cannot able to insert/update data in a non-updatable object. Instead if your org contains data in that object, then you can fetch data from that object in the test method like the following.

 

@isTest(SeeAllData=True)

public class MytestClass{

public testmethod void myTestMethod(){

List<OpportunityPartner> oppPartnerList = new List<OpportunityPartner>();

oppPartnerList = [SELECT Id FROM OpportunityPartner];

//then USE "oppPartnerList" for your operation.

}

}

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks