You need to sign in to do that
Don't have an account?

Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required?????
I am getting the error above. The code is below. I have systematically removed all code from this trigger to try and pinpoint what is generating this error. This what is left and it still generates the error;
trigger UpdCnt on Account (after update) {
List<Contact> cnt = new List<Contact>();
}
Obviously this trigger does nothing. If I take out the one line that's in there it will Save to the Server.
Any suggestions?
Austin_Steve
Hello Austin_Steve
The problem isn't with your trigger code itself. Check out what the error message says "Test coverage of selected Apex Trigger...". ie. this is about "Test coverage".
Doing a search (top right) I found this post - check out its Solution:
http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=6046#M6046
You'll notice they've got another class that creates an instance of the object, inserts it, and verifies that the trigger's actions are called out. Also check out this article An Introduction to Apex Code Test Methods.
Hope that helps
Jon
All Answers
Hello Austin_Steve
The problem isn't with your trigger code itself. Check out what the error message says "Test coverage of selected Apex Trigger...". ie. this is about "Test coverage".
Doing a search (top right) I found this post - check out its Solution:
http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=6046#M6046
You'll notice they've got another class that creates an instance of the object, inserts it, and verifies that the trigger's actions are called out. Also check out this article An Introduction to Apex Code Test Methods.
Hope that helps
Jon
Hi Mohi
Your question has nothing to do with Triggers, which is what this thread is about. To stand more of a chance of someone finding your question and answering it, I suggest posting it to the Visualforce board.
Thanks!
Jon
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?