You need to sign in to do that
Don't have an account?
Urgent need test class for Trigger
trigger PhysicianVisit_AI_UpdateUnplannedCall on Physician_Visit__c (after Insert)
{
if(Trigger.isInsert)
{
try
{
if(clsPhysicianVisitUpdate.isInsert == false)
{
clsPhysicianVisitUpdate.isInsert = true;
clsUpdateFuturePhysicianVisits oclsUpdateFuturePhysicianVisits = new clsUpdateFuturePhysicianVisits();
oclsUpdateFuturePhysicianVisits.updateFuturePhysicianVisits(trigger.new,'insert');
}
}
catch(Exception e)
{
Trigger.New[0].addError('Error occurred in Updating future Physician Visits - ' + e);
}
}
}
Hi,
For triggers, u just write the testmethod like below:
You write the trigger for after insert operation. So, you just write the test method like;
@isTest
static testMethod void testAcceptFailedSalesClaimDataTrigger(){
Account acc = new Account(Name = 'My Company123');
insert acc;
}
Like above example, u replace the Account with your custom object 'Physician_Visit__c' and give the required fields and insert that record.
Then, trigger will automatically fired, test coverage also u can check in Apex Test Run.
Regards,
Phanikumar
not getting and also it's not working
Hi,
could you pls post the test class which we have written for this trigger. Let me check and i will make the necessary changes.
Regards,
Phanikumar
Hi,
Please check this site, it will helpful to you.
http://developer.force.com/cookbook/recipe/controlling-recursive-triggers
Regards,
Phanikumar
Thanks for your quick reply here i am sending the sample test class code
@isTest
private class physician{
static testmethod void physician(){
physician__c ph = new physician__C();
ph.book__C='test';
ph.date_visit=system.today();
insert ph;
try
{
ph.book__C='test1';
update ph;
}catch
{
System.debug(Logginglevel.ERROR, 'ERROR: ' + e.getMessage() );
}}}
As the Trigger is written on Physician_Visit__c object try creating a new instance of this object and insert the test data.
you can Type:
Physician_Visit__c ph = new Physician_Visit__c();
instead of:
physician__c ph = new physician__C();
Hope this helps!
Regards
Sam
Hi,
Based on the below code, i need clarification about the "clsPhysicianVisitUpdate". Is that controller used for insertion operation. are is there any relationship from this object to other object.
Because, w.r.t the below condition, you are performing certain action, which should be done after the insertion of record into the "Physician_Visit__c" object.
if(clsPhysicianVisitUpdate.isInsert == false) {
clsPhysicianVisitUpdate.isInsert = true;
clsUpdateFuturePhysicianVisits oclsUpdateFuturePhysicianVisits = new clsUpdateFuturePhysicianVisits();
oclsUpdateFuturePhysicianVisits.updateFuturePhysicianVisits(trigger.new,'insert');
}
So, please provide the need ful informtaion which helps to write the test class.
Regards,
Phanikumar