![](https://www.infallibletechie.com/wp-content/uploads/2023/03/Fetch-Standard-Price-Book-Id-in-Salesforce-Test-Class-1024x576.jpg)
Test.getStandardPricebookId() is used to get or fetch the Standard Price Book Id in the Apex test class.
Sample Code:
Id pricebookId = Test.getStandardPricebookId();
Sample Apex Test Class:
@isTest
private class ProductTestClass {
static testMethod void testPriceBook() {
Id pricebookId = Test.getStandardPricebookId();
Assert.isNotNull( pricebookId );
}
}