You need to sign in to do that
Don't have an account?

Hi All, is it possible we can write a soql querys in test class
Hi All,
is it possible we can write a soql querys in test class .
Regards,
Viswa:)
is it possible we can write a soql querys in test class .
Regards,
Viswa:)
Yes, it is possible!! but you need write SeeAllData=true(as like below) for access org data.
@isTest(SeeAllData=true)
Yes,it is possible to write a soql in test class using @IsTest(SeeAll=True) Annotation.
Annotate your test class or test method with IsTest(SeeAllData=true) to open up data access to records in your organization.
Considerations for the IsTest(SeeAllData=true) Annotation:
- If a test class is defined with the isTest(SeeAllData=true) annotation, this annotation applies to all its test methods whether the test methods are defined with the @isTest annotation or the testmethod keyword.
- The isTest(SeeAllData=true) annotation is used to open up data access when applied at the class or method level. However, using isTest(SeeAllData=false) on a method doesn’t restrict organization data access for that method if the containing class has already been defined with the isTest(SeeAllData=true) annotation. In this case, the method will still have access to all the data in the organization.
For more information please follow the below linkhttps://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_seealldata_using.htm