Keywords or functions in Test classes

KeywordKeywords or functions in Test classes:

@isTest Annotation:
This annotation is used to define the test class. If we use this annotation then data which we created inside the method doesn’t count against your organization limit. Can be created the method declared as “private” or “public”.

If we use this keyword seeAllData=true , then we get all the data from database. This will be a problem because the data is vary from instance to instance.
seeAllData=false, is not access to the data in the system ,whatever the data need in the test class we have to create in class it slef. Always better to use this method because data will be same for all instances.

This keyword/function is used only in test method, generally Apex code is running in system mode not in user mode and permission and record sharing of the current user are not taken as count.
If we have to call the piece of code which will be execute with specific user then we can use this function.

This keyword/function we can use only in classes not in test classes.
When we have to call the piece of code only from test class then we can use this.
This is Boolean variable return true when calling from test class otherwise false.

Leave a Reply