You need to sign in to do that
Don't have an account?
David Hagen
code coverage in triggers can't increase
Hi, I've a trigger on insert and update task. I uses both API and Web to insert/update task. I would like to stop triggers when they are updated by API. So, added a filter to check if the user is API then do nothing. I can't increase the code coverage in the following code
trigger XmsTaskTrigger on Task (after insert, after update) {
Task[] tsk = Trigger.new;
String JSONString = JSON.serialize(tsk);
if(UserInfo.getProfileId()!='API'){
XmsTask.doCallout(JSONString);
}
}
If I remove if(UserInfo.getProfileId()!='API') I get 94% code coverage otherwise i get 50%
trigger XmsTaskTrigger on Task (after insert, after update) {
Task[] tsk = Trigger.new;
String JSONString = JSON.serialize(tsk);
if(UserInfo.getProfileId()!='API'){
XmsTask.doCallout(JSONString);
}
}
If I remove if(UserInfo.getProfileId()!='API') I get 94% code coverage otherwise i get 50%
Otherwise, you may need to run the unit test as certain users with certain profiles.
Help site looks down right now:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_tools_runas.htm
What do the debug logs show?
All Answers
Otherwise, you may need to run the unit test as certain users with certain profiles.
Help site looks down right now:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_tools_runas.htm
What do the debug logs show?
Also try if(1=1) and see what happens... all good story building info.
If you uncover the issue please post back what you found. Thanks!