You need to sign in to do that
Don't have an account?
Andrew Hoban 6
Issue creating Test Class
Hi all,
I was wondering if anyone could provide a test class for the class provided below.
Thanks
I was wondering if anyone could provide a test class for the class provided below.
Thanks
public class IncidentLogPopup{ public List<Incident_Log__c> incidentLogList { get; set; } public List<Incident_Log__c> memberAddList { get; set; } //remove this public Boolean isValidState { get; set; } public String memberName {get;set;} public string searchstring {get;set;} private Id matchDayOpsId; public PageReference cancel(){ return new PageReference('/'+matchDayOpsId); } private IncidentLogPopup(){} public IncidentLogPopup(ApexPages.StandardController controller) { isValidState=false; try { if (!ApexPages.CurrentPage().getParameters().containsKey('Id')) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Parameters.')); return; } matchDayOpsId = ApexPages.CurrentPage().getParameters().get('Id'); String q = 'SELECT Match_Day_Ops__c, Date_Time__c, Date_Closed__c, Type__c, Incident_Closed__c,'; q+='Priority__c, Incident__c, Reported_to__c, Reported_By__c, Opened_Closed_Status__c'; q+=' from Incident_Log__c'; q+=' where Match_Day_Ops__c=\''+matchDayOpsId+'\''; incidentLogList = Database.Query(q); if (incidentLogList.size()==0){ incidentLogList.add(new Incident_Log__c(Match_Day_Ops__c = matchDayOpsId, Date_Time__c = DateTime.Now())); } isValidState=true; } catch(Exception e){ ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage())); } } public Pagereference addRow(){ incidentLogList.add(new Incident_Log__c(Match_Day_Ops__c = matchDayOpsId, Date_Time__c = DateTime.Now())); return null; } Public Pagereference quickSave(){ upsert incidentLogList; return null; } public PageReference save(){ return null;} //remove this }
Please create test data in above test class.
For VF page we need to use below code in Test classes
ApexPages.StandardController controllerer = new ApexPages.standardController(inLog);
IncidentLogPopup testClass= new IncidentLogPopup(controllerer);
Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help