1.RunAs will use the record sharing view-ability of a record when viewing. It doesn't respect user permissions or FLS.
2.You can only use RunAs in test methods, and it doesn't respect user license limits.
The runAs method ignores user license limits. You can create new users with runAs even if your organization has no additional user licenses.
3.RunAs can be used for mixed DML exceptions that would normally occur.
4.RunAs can take a package version as an argument.
ex :
// Run test as managed package version 1.0
System.runAs(new Version(1,0)){
try{
insert o;
}
catch(System.DMLException e){
System.assert(false, e.getMessage());
}
}
No comments:
Post a Comment