+ Start a Discussion
Pascal tagPascal tag 

Domain Pattern - fflib_SObjectDomain - Test.Database.hasRecords()) ?

Hi,

I'm exploring fflib_SObjectDomain (Domain Pattern) :
https://github.com/apex-enterprise-patterns/fflib-apex-common

I'd like to understand the origin of this particular code (from fflib_SObjectDomain class, line )  :
if (System.Test.isRunningTest() & Test.Database.hasRecords())...

Where does Test.Database.hasRecords() come from ?

I can't find any reference. For instance, Test.isRunningTest() comes from Test Class (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_test.htm).

I have looked for any other classes in fflib-apex-common but didn't find any reference.
System.Test.isRunningTest() can be called from anonymous window in devloper console. Not Test.Database.hasRecords()
I've looked inside fflib_SObjectDomain class but I don't find any method or property...

Any idea ?
ShirishaShirisha (Salesforce Developers) 
Hi Pascal,

Greetings!

If I understand it correctly,Test.Database.hasRecords() is a pre-defined method which will be used to check if we have test records or not.Also,Test() is the predefined class which can be used to access the data created in Test class.

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri