You need to sign in to do that
Don't have an account?
Rishav
test classe for controller extension
Hii,
I am Writing a test class for cotroller but it is not getting pass , it is always throwing error in the controller part as"DML Exception".
This is my extension class
And this is my test class for passing the controller
I am using the standard controller case. But it is giving me error.
I am Writing a test class for cotroller but it is not getting pass , it is always throwing error in the controller part as"DML Exception".
This is my extension class
public CPCommAttachCls(ApexPages.StandardController stdController) { objId = ApexPages.currentPage().getParameters().get('CaseID'); objCaseRec = [select CaseNumber, Subject from case where case.id =: objId]; caseNumber = objCaseRec.CaseNumber; subject = objCaseRec.Subject; // initializing caseComment comment = new CaseComment(); comment.parentid=objid; // initializing the variable for Attachment process CaseAttachment = new Attachment(); CaseAttachment.parentId=objid; } // Controller scope finished
And this is my test class for passing the controller
@isTest(SeeAllData=true) public class CPCommAttachTestCls { public static TestMethod void Testclass() { // CaseComment comment = new CaseComment(); Case c = Cse(); ApexPages.StandardController sc = new ApexPages.StandardController(c); CpCommAttachCls ContCls = new CpCommAttachCls(sc); // This line giving error } static Case cse(){ Case c = new Case(); c.subject = 'LogMeIn Pro2'; c.Description='Test Description'; c.General_App_Area__c='A'; c.Priority='High'; c.Status='New'; insert c; return c; } }
I am using the standard controller case. But it is giving me error.
This is because the record id when coming from the standard controller is 'id' not 'CaseId'