You need to sign in to do that
Don't have an account?
Angie Yzaguirre
writing a class to an old trigger
I am trying to deploy a trigger, but a very old trigger is holding up the process because it does not have any code coverage:
Can anyone help me write a class to make this code have at least 1% coverage??
Can anyone help me write a class to make this code have at least 1% coverage??
If you are deploying a trigger then you must have covered the coverage for that trigger, then I think you know how to write a test class. Even if this trigger is not in your current environment, you can write a test class for it.
Say
Benchmark__c bench = new Benchmark__c() ;
This will initiate your trigger but you should know what all are your required fields you need to enter.
Thanks
Ankit
Like you mentioned, triggers need "non-zero" unit testing, meaning if you invoke the trigger via a test method, you should be able to deploy if your overall code coverage is > 75%. That being said, all you should need to do (for the bare minium) is to create a test method that inserts a Benchmark__c record. Ankit was ALMOST correct, but he left out the insert statement. Here's what your test method might look like:
@isTest
private testCalculateRollups{
static testmethod void testInsert(){
Benchmark__c bench = new Benchmark__c();
insert bench; // should invoke your trigger.
}
}
In addition to the bare bones test, you'll also want to add criteria to test out the various conditions in the trigger, along with System.assert calls to verify your trigger is working properly. For more on that see the following sites:
[Error] Error: Compile Error: unexpected token: 'testCalculateRollups' at line 2 column 8
Along with that error, is there a way to know what the various conditions of the trigger are?