You need to sign in to do that
Don't have an account?
Snehal Gaware 15
test class for apex class.. need help
Hi,
I need help in writting test class for following class.
Thanks in advance. any help will be appreciated.
I need help in writting test class for following class.
public class Populate { public Case cs{get;set;} public SC_Problem_Management__c prblm{get;set;} public ApexPages.StandardController stdCntrlr {get; set;} public Populate(ApexPages.StandardController controller) { cs = new Case(); prblm = new SC_Problem_Management__c(); prblm = (SC_Problem_Management__c)controller.getRecord(); //Get the ID of Currently present case on vf page String csId = [SELECT Id FROM Case WHERE Id =: prblm.Case__c].Id; System.debug('testing'+ csId); prblm.Case__c= csId; if(csId != null) { //calling autofilling method autoCal(); } } //function is called from actionsupport event public void autoCal() { Id caseid = prblm.Case__c; // collecting case id from visualforce page if(caseid!=null){ List<Case> caseLst = [select id,Products__c,Componet__c ,Feature__c,Status,Priority,Subject,Description__c,Assignment_Group__c from Case where id=:caseid]; system.debug('Product'+ caseLst[0].Products__c); if(!caseLst.isEmpty()) { prblm.Products__c= caseLst[0].Products__c; prblm.Component__c = caseLst[0].Componet__c; prblm.Feature__c = caseLst[0].Feature__c; prblm.Status__c = caseLst[0].Status; prblm.Priority__c = caseLst[0].Priority; prblm.Title__c=caseLst[0].Subject; prblm.Issue_Escape__c=caseLst[0].Assignment_Group__c; prblm.Description__c= caseLst[0].Description__c; } } } public pagereference Save() { insert prblm; pagereference pr = new pagereference('/'+prblm.id); System.debug('pagereference/////'+pr); return pr; } }
Thanks in advance. any help will be appreciated.
All Answers
i have tried your code as well but it is giving code coverage as None.
Could you please help me with below class for test class