Q: 6
A developer at AW Computing is tasked to create the supporting test class for a programmatic
customization that leverages records stored within the custom object, Pricing Structure c. AW
Computing has a complex pricing structure for each item on the store, spanning more than 500
records.
Which two approaches can the developer use to ensure Pricing _Structure__c records are available
when the test class is executed?
Choose 2 answers
Options
Discussion
A and C make sense here. Using a Test Data Factory (A) or Test.loadData() (C) actually creates the test records needed, so you’re not relying on org data that might not exist. I think that fits best, but open if someone sees it differently.
B . @IsTest(SeeAllData=true) should let you access the Pricing_Structure__c records if they're already in the org. I know it's not best practice, but technically it works unless test isolation is enforced. Maybe I'm missing a restriction?
B , since @IsTest(SeeAllData=true) lets test classes access existing data in the org. I encountered exactly similar question in my exam and picked B for that reason. I see A is best practice but if the records are there, B technically works. Anyone else picked this?
I still think A and B, since @IsTest(SeeAllData=true) might let you grab the needed records if they're already there.
A and C imo, B depends on org data which isn't safe for tests.
I don't think B is right here. Using @IsTest(SeeAllData=true) is risky because it depends on org data, and tests should use data they create. A and C are definitely the safe bets, especially when you've got lots of records to set up like in this scenario. D is a trap since 'without sharing' affects sharing, not data setup.
Not B. @IsTest(SeeAllData=true) should be avoided unless you have no choice-it's not best practice and makes tests unreliable. A and C both let you control the data: Test Data Factory for flexibility, Test.loadData for bulk importing. Anyone disagree?
A and C tbh, matches what I've seen in other practice sets. Test Data Factory is great for reusable test data, and Test.loadData() handles big datasets efficiently. Really clear options here, much better than some of the wordy ones.
Be respectful. No spam.