You need to sign in to do that
Don't have an account?
sailer
@Test Class for befor insert
Hello evryone,
I have wrote the code
trigger updatebody on Property_Obj__c (before update)
{
Property_Obj__c pro= new Property_Obj__c();
List<Property_Obj__c> porpetylsit= new List<Property_Obj__c>();
for (Property_Obj__c newprop: Trigger.new) {
Property_Obj__c oldprop = Trigger.oldMap.get(newprop.Id);
if (oldprop.Counter_No__c != newprop.Counter_No__c) {
Frequency__c frequency = [Select ID, Subject__c, Body__c from Frequency__c where Counter_No__c = : newprop.Counter_No__c];
newprop.Subject__c = frequency.Subject__c;
newprop.Body__c = frequency.Body__c;
}
}
}
But when i run the test class through Ecclipse i get 0 Lines not tested ,100 % covered .But its
giving the error has Multiple markers at this line
- Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is
required
- File only saved locally, not to server
Can you please help out to write the test class for the above trigger
Thanks,
Sailer
I have wrote the code
trigger updatebody on Property_Obj__c (before update)
{
Property_Obj__c pro= new Property_Obj__c();
List<Property_Obj__c> porpetylsit= new List<Property_Obj__c>();
for (Property_Obj__c newprop: Trigger.new) {
Property_Obj__c oldprop = Trigger.oldMap.get(newprop.Id);
if (oldprop.Counter_No__c != newprop.Counter_No__c) {
Frequency__c frequency = [Select ID, Subject__c, Body__c from Frequency__c where Counter_No__c = : newprop.Counter_No__c];
newprop.Subject__c = frequency.Subject__c;
newprop.Body__c = frequency.Body__c;
}
}
}
But when i run the test class through Ecclipse i get 0 Lines not tested ,100 % covered .But its
giving the error has Multiple markers at this line
- Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is
required
- File only saved locally, not to server
Can you please help out to write the test class for the above trigger
Thanks,
Sailer
@isTest
private class test_PropertyObjectTrigger {
static testMethod void testUpdate()
{
Frequency__c freq = new Frequency();
freq.subject__c='test';
freq.body__c='test';
freq.counter_no__c = 1; //assuming this is number field, change to text if needed.
//**Add any other field requirements here.
insert freq;
Property_Obj__c prop = new Property_Obj__c();
prop.name = 'test'; //assuming a name field is present and required.
//**Add any other field requirements here.
insert prop;
prop.counter_no__c = 1; //assuming this is number field, change to text if needed.
update prop;
}
}