You need to sign in to do that
Don't have an account?

Help Test Class
Hi Experts,
Please help me test class for below trigger.
Trigger AccountandContactUpdateTrigger on Case(before insert, before update){
List<String> AccNoSet = new List<String>();
for(Case c: trigger.new){
AccNoSet.add(c.Account_Number__c);
}
Map<String, Account> AccMap = new Map<String, Account>();
for(Account acc : [SELECT Id, Parent_VRP_Number__c, VRP_Account_Number__c from Account where VRP_Account_Number__c IN :AccNoSet]){
AccMap.put(acc.Parent_VRP_Number__c , acc);
}
for(Case c:trigger.new){
c.Accountid = AccMap.get(c.Account_Number__c).id;
if(c.accountid!=null){
List<Contact> ConList = [select id, name from Contact where accountid =:c.accountid];
if(!ConList.isempty()){
c.Contactid = ConList[0].id;
}
}
}
}
Regards,
Sai
Please help me test class for below trigger.
Trigger AccountandContactUpdateTrigger on Case(before insert, before update){
List<String> AccNoSet = new List<String>();
for(Case c: trigger.new){
AccNoSet.add(c.Account_Number__c);
}
Map<String, Account> AccMap = new Map<String, Account>();
for(Account acc : [SELECT Id, Parent_VRP_Number__c, VRP_Account_Number__c from Account where VRP_Account_Number__c IN :AccNoSet]){
AccMap.put(acc.Parent_VRP_Number__c , acc);
}
for(Case c:trigger.new){
c.Accountid = AccMap.get(c.Account_Number__c).id;
if(c.accountid!=null){
List<Contact> ConList = [select id, name from Contact where accountid =:c.accountid];
if(!ConList.isempty()){
c.Contactid = ConList[0].id;
}
}
}
}
Regards,
Sai
Check below test class: Thanks,
Dhanya
Please try to strat writing test class and let us know when you will face problem .Why I am telling ,bacause it wil help you to learn so that you will confident to write test class in future .
Also your trigger have issue in coding standard .you have query inside for loop which willl give you 101 SOQL error in near future .
Check with below link it will help to start .
http://manojjena20.blogspot.in/2015/06/tips-and-tricks-for-test-class.html
Incase you have started please post your code so that we wil hlep you to reach 100% and code coverage and all functional test case .
Thanks
Manoj
Please update your trigger as below to avoid 101 SOQL error And please try below test class
Let us know if this will help you
Thanks
Amit Chaudhary