You need to sign in to do that
Don't have an account?
Gorky
Apex Trigger Test Coverage
Hi Everyone,
I'm trying to deploy my first Apex trigger to PRODUCTION but not pases the validation I only made the 69% of 75%.
I don't know what I'm missing.
First I check the user who's launched the trigger. Then if is not a administrator I call the method MyMethod in the class ThisClass, and I pass the values of the Orders table who has been changed.
The class is tested and is correctly deployed.
Thanks in advance.
The code --> :
trigger Order_UPDATE on Orders (before update) {
string userrole = UserInfo.getUserRoleId(); --> Get UserRoleId
if (userrole != 'Administrator'){ --> If is not administrator enter the IF
Orders[] accs = Trigger.new; --> Get the values
This_Class.MyMethod(accs); --> Pass it to the method
}
}
I'm trying to deploy my first Apex trigger to PRODUCTION but not pases the validation I only made the 69% of 75%.
I don't know what I'm missing.
First I check the user who's launched the trigger. Then if is not a administrator I call the method MyMethod in the class ThisClass, and I pass the values of the Orders table who has been changed.
The class is tested and is correctly deployed.
Thanks in advance.
The code --> :
trigger Order_UPDATE on Orders (before update) {
string userrole = UserInfo.getUserRoleId(); --> Get UserRoleId
if (userrole != 'Administrator'){ --> If is not administrator enter the IF
Orders[] accs = Trigger.new; --> Get the values
This_Class.MyMethod(accs); --> Pass it to the method
}
}
In your test class you would need to have something like :
Hope this helps,
David
Message Edited by David VP on 10-09-2008 05:10 PM
Thanks again David VP
I modified an apex class and I am trying to save it in Salesforce.
The strange thing is that the "deployment result" is failed and the errors are referring to triggers already existing in Salesforce! The message says: "test coverage of selected apex trigger is 0%".
How can this be possible?
I have a similar question that I'm hoping someone will help me with, I'm new to Apex.
I have a very simple lookup-field trigger that places a record ID in that field, on a custom "Accounts" object, not the standard object:
trigger SetAccountField on Account__c (before insert, before update) {
for (Account__c Account__c : Trigger.new) {
a.Scoring__c = 'a00A0000003MnLw';
}
}
How can I create a test class, for something like this? Can you give me an example of the best way to test something this simple?