You need to sign in to do that
Don't have an account?
junkiy
Salesforce test Class Code coverage any one help me i trying to write test class.
trigger IssuerUpdate on Issuer__c (before insert,before update)
{
//Recursive Trigger So using this
if(trigger_handler.runOnce()){
//New Record Insert
for(Issuer__c n : trigger.new)
{
//Checking the Condtion Status Feild
if(n.Status__c== 'Approved'){
//Getting the Query Already existing All feilds
list<Issuer__c> iss = [SELECT Id,RevQ1__c,RevQ3__c,RevQ0__c,RevQ2__c FROM Issuer__c where id =:n.id];
for(Issuer__c is :iss){
//RevQ0 values 1
n.RevQ3__c= n.RevQ1__c;
n.RevQ2__c= is.RevQ1__c;
n.RevQ3__c=is.RevQ2__c;
n.RevQ4__c=is.RevQ3__c;
//Rev 2
}if(n.Status__c== 'Approved'){
n.RevQ0__c=0;
}
}
}
}
}
{
//Recursive Trigger So using this
if(trigger_handler.runOnce()){
//New Record Insert
for(Issuer__c n : trigger.new)
{
//Checking the Condtion Status Feild
if(n.Status__c== 'Approved'){
//Getting the Query Already existing All feilds
list<Issuer__c> iss = [SELECT Id,RevQ1__c,RevQ3__c,RevQ0__c,RevQ2__c FROM Issuer__c where id =:n.id];
for(Issuer__c is :iss){
//RevQ0 values 1
n.RevQ3__c= n.RevQ1__c;
n.RevQ2__c= is.RevQ1__c;
n.RevQ3__c=is.RevQ2__c;
n.RevQ4__c=is.RevQ3__c;
//Rev 2
}if(n.Status__c== 'Approved'){
n.RevQ0__c=0;
}
}
}
}
}
I saw your trigger is not followed by best practice of salesforce ,you should not query inside for loop .try to create some map and make the query out side loop . I dont think query is required here any way query will not return any thing incae of before insert .
I think below code will help for you .
For test class you need to just insert Issuer__c records and update .
Your code is simple ,try to follow below and start writting test class .
Whats the problem you are facing ?
http://manojjena20.blogspot.com/2015/06/tips-and-tricks-for-test-class.html (http://Whats the problem you are facing ? Try to floow below links it will help . http://manojjena20.blogspot.com/2015/06/tips-and-tricks-for-test-class.html (https://trailhead.salesforce.com/en/content/learn/modules/apex_testing/apex_testing_intro) https://trailhead.salesforce.com/en/content/learn/modules/apex_testing/apex_testing_intro Try to run the test class in you rorganisation , you can install code coverage calculator chrome extension which will help you to identify the line which covered . Thanks , Manoj)
https://trailhead.salesforce.com/en/content/learn/modules/apex_testing/apex_testing_intro
https://trailhead.salesforce.com/en/content/learn/modules/apex_testing/apex_testing_intro
Try to run the test class in you rorganisation , you can install code coverage calculator chrome extension which will help you to identify the line which covered .
Thanks ,
Manoj