+ Start a Discussion
SirTravSirTrav 

Test method for OpportunityPartner

I have a class that makes some updates based on OpportunityPartner.  I am working on the test method but am not sure how to create an OpportunityPartner to use for the test.  When I try to insert an OpportunityPartner it says that DML is not allowed which makes sense because OpportunityPartner is a read only object.  So what I want to know is how do I run a test method when my class relies on at least 1 OpportunityPartner being created? 

Best Answer chosen by Admin (Salesforce Developers) 
Suresh RaghuramSuresh Raghuram

If i am in your place i will create all the necessary record to run the test method. Since OpportunityPartner is Read only object

i will take care while creating the records should meet the one of the specific opportunityPartner. Then i will do query in the test method and utilise it for the test method.

 

If this helps u make this as a solution. give KUODs

All Answers

Suresh RaghuramSuresh Raghuram

If i am in your place i will create all the necessary record to run the test method. Since OpportunityPartner is Read only object

i will take care while creating the records should meet the one of the specific opportunityPartner. Then i will do query in the test method and utilise it for the test method.

 

If this helps u make this as a solution. give KUODs

This was selected as the best answer
SirTravSirTrav

Suree wrote:

If i am in your place i will create all the necessary record to run the test method. Since OpportunityPartner is Read only object

i will take care while creating the records should meet the one of the specific opportunityPartner. Then i will do query in the test method and utilise it for the test method.

 


I tried this and in my test method when I use list<OpportunityPartner> OP = [select id from OpportunityPartner]; it returns 0 results even though there are some in the system.  

SirTravSirTrav
found that I have to add @istest(SeeAllData=true) to see the existing data. thanks for the help.