@isTest
private class methodonetest {
private static Account acc;
private static Opportunity Opp;
private static Quote Q;
private static Product2 prd;
private static QuoteLineItem Qli;
@testSetup static void testData(){
acc = new Account();
acc.Name = 'TestAccount';
insert acc;
Opp = new Opportunity(Name=acc.Name + ' Opportunity ',
StageName='Prospecting',start_date__c = system.today(),end_date__c = system.today()+45,
CloseDate=System.today().addMonths(3),
AccountId=acc.Id);
insert Opp;
prd = new product2(name='unittestproduct');
prd.Family = 'License';
insert prd;
Pricebook2 stdPb = [select Id,name, isactive from Pricebook2 where IsStandard = true limit 1];
//Id t = Test.getStandardPricebookId();
//insert stdPb;
PricebookEntry pbe = new PricebookEntry(pricebook2id = stdPb.Id, product2id = prd.id,unitprice=1.0,isActive=true);
insert pbe;
q=new quote(name='myquotetest',opportunityid=opp.id,pricebook2id=stdPb.Id, status='Draft');
insert q;
quoteLineItem i = new quotelineitem();
i.quoteid = q.id;
i.pricebookentryid = pbe.id;
i.quantity = 1;
i.unitprice = 1;
insert i;
}
@istest(SeeAllData=true)
static void testApexPageMessages(){
Test.startTest();
//CreateOrderFromQuote s = new CreateOrderFromQuote();
CreateOrderFromQuote.UpdateStatusField(q.Id);
Test.stopTest();
}
}
This is my test class.
I'm getting the error:
Test class containing a test setup method cannot have any methods
annotated with @isTest(SeeAllData=true)
I need seeattdata=true as i;m using standard pricebbok2.
can someone help me how to solve the issue?
Best Answer
According to this link
So either remove the annotation of @testsetup and call your static method in the test method or try and do the test without the SeeAllData attribute