+ Start a Discussion
Abhishek Kumar 149Abhishek Kumar 149 

how to create virtual record for Profile in test class?

Vickal GuptaVickal Gupta
Hi Abhishek,

You don't have to create Profile in Test class.
All you need to do is query it from your Org. Refer below example:
Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
You can change name('System Administrator') based on requirement. And then you can use profile Id (p.Id) in your test classes.

Hope this will help you.