+ Start a Discussion
LiptonLipton 

Help with Test Trigger

Hi Everyone,

 

I'm having a problem with Test Trigger it says 0%, I've done reasearch but still no luck or no idea how to do it.

my code as follows;

 

 

trigger disabilityChecked on Care_Recipient_Information__c (before insert, before update)
{

 

Boolean disability, chronic;

 

for (Care_Recipient_Information__c obj : Trigger.new)

{


if ((obj.DMD__c == true) ||
(obj.DS__c == true) ||
(obj.Learning_Disability__c == true) ||
(obj.Spina_Bifida__c == true) ||
(obj.Hearing_Disability__c == true) ||
(obj.Visual_Disability__c == true) ||
(obj.Dyslexia__c == true) ||
(obj.Physical_Disability__c == true) ||
(obj.Rare_Syndromes__c == true) ||
(obj.ID__c == true))


{
obj.DisabilityNumber__c = 1;
disability = true;
obj.Disability__c = disability;
}

 

else
{
disability = false;
chronic = false;
obj.Disability__c = disability;
//obj.chronic_Illness__c = chronic;
}

 

}//FOR

}//END

 

Thank you for the assistance,

venkateshyadav1243venkateshyadav1243

Hi try this

 

@istest
public class test_Care_Recipien
{
public static testmethod void test_care()
{
Care_Recipient_Information__c cr=new Care_Recipient_Information__c();
cr.DMD__c = true;
cr.DS__c = true;
cr.Learning_Disability__c = true;
cr.Spina_Bifida__c = true;
cr.Hearing_Disability__c = true;
cr.Visual_Disability__c =true;

cr.Dyslexia__c = true;
cr.Physical_Disability__c = true;
cr.Rare_Syndromes__c =true;
cr.Disability__c=true;
insert cr;
cr.DMD__c =false;
cr.DS__c = false;
cr.Disability__c=false;
update cr;
}
}

 

regards

venkatesh

LiptonLipton

didn't work.

it still says 0%

Shivanath DevnarayananShivanath Devnarayanan
It might say zero on the Trigger Listing,
But check when you run the test class you can see the coverage through each Trigger.

Also it might help if you click Setup --> Apex Classes --> Compile all Classes

Let me know this solves your issue
LiptonLipton
well I'm still stuck at the The Eclipse IDE, they stop me to save on the server copy.
Vinit_KumarVinit_Kumar

Lipton,

 

Try below :-

 

@IsTest(SeeAllData=true)
public class test_Care_Recipien
{ 
static testmethod void test_care()
{
Care_Recipient_Information__c cr=new Care_Recipient_Information__c(DMD__c = true,DS__c = true,Learning_Disability__c = true,Spina_Bifida__c = true,Hearing_Disability__c = true,Visual_Disability__c =true); // Insert all the mandatory field values for Care_Recipient_Information__c to insert a record

insert cr;

cr.DMD__c =false;
cr.DS__c = false;
cr.Disability__c=false;
update cr;
}
}

 

LiptonLipton
Still no dice, is there a way to put some test method in triggers?

Thanks.
LiptonLipton
LiptonLipton

got it covered 100% http://s23.postimg.org/y7m5divm3/Covered.jpg
but it won't let me post onto the server http://s15.postimg.org/p7brlg38r/block.jpg

 

err.. kinda frustrating, help! :(.