[SalesForce] How to get standardPriceBook id in Test class

I want to access Standard PriceBookEntry ID in my Test Class.

I know by using @isTest(SeeAllData=true) we can create one. But, my requirement is not to use (SeeAllData=true).

I also thought to make a Standard PriceBookEntry ID entry in Custom Setting and access it in Test Class, but here also without (SeeAllData=true) we can't access Custom Setting.

So, any workaround/solution for this?

Best Answer

This was updated recently. You can leave SeeAllData=false and still access the standard pricebook now. See link

Test.getStandardPricebookId