I'm creating a test class right now and one of the things I need to test is whether the ProductCode of a quotelineItem for a certain Quote starts with 'MA' or not. However, when I create a new test class, I can't specify the product code for a QuoteLineItem. How should I go about doing this so that I can properly test out my class?
Here is what I'm attempting to do right now but I'm getting an error saying "Field is not writeable: QuoteLineItem.product_Code__c".
Product2 testProduct1 = TestUtil.initProduct2(); //This is my test utility class where I initialize any and all objects that I will need during a test class.
List<QuoteLineItem> qlis=[Select Id,QuoteId from QuoteLineItem where QuoteId=:quoteId];//new List<QuoteLineItem>{qlitem,qlitem2};
for (QuoteLineItem q:qlis){
if (q.Product_Code__c==null){
String qProductCode='MAR-3232-2323';
q.Product_Code__c=testProduct1.ProductCode;
// and I have also tried
q.Product_Code__c=qProductCode;
//both of these methods do not work when trying to set the Product Code for a quoteLineItem.
}
}
Whats the proper way of going about this? Thanks!