You need to sign in to do that
Don't have an account?
Sebastian Page
Need help on Test class and code coverage
Hello All, I am facing issue on test class. My test class execute successfully but code coverage is None please Help.
My apex class here
@istest
public class CommenttoEmailTest {
static testMethod void testMatching(){
// Id rtId = [select Id, name from RecordType where name = 'Massbay_Ticket' and SObjectType = 'Case' limit 1].Id;
//create account
Account acc = new Account();
//enter details
acc.Name = 'Test Account';
//Add other fields
insert acc;
// create test contact
Contact con = TestUtilityController.getContact('Test Last Name','testing@testing.com',acc.Id);
insert con;
// Create test cases
List<Case> listCase = new List<Case>();
if(UtilityController.caseRecordType.containsKey('Massbay_Ticket')){
String recordTypeId = UtilityController.caseRecordType.get('Massbay_Ticket').Id;
Case csa = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
//enter details
//Add other fields
csa.Ticket_Category__c='Blackboard learn';
csa.Status = 'Action-Automated Escalation';
insert csa;
PageReference pageRef = Page.MyNew_commentvf;
pageRef.getParameters().put(recordTypeId, String.valueOf(csa.Id));
Test.setCurrentPage(pageRef);
CaseComment tComment = new CaseComment();
tComment.ParentId = Csa.Id;
tComment.CommentBody = 'Some Comment';
tComment.IsPublished = TRUE;
insert tComment;
tComment.CommentBody = 'Inporgreess Comment';
update tComment ;
ApexPages.StandardController sc = new ApexPages.StandardController(csa);
CommenttoEmail testCmEmail = new CommenttoEmail (sc);
testCmEmail.senttoEmail();
testCmEmail.bccEmail();
testCmEmail.ccEmail();
testCmEmail.attachemail();
testCmEmail.createCaseComment();
testCmEmail.sendingEmail();
testCmEmail.ss();
testCmEmail.ChangeStatus();
testCmEmail.getCaseStatus();
testCmEmail.upload();
}
}// end of test method
}// end of Class
and my test class is
@istest
public class CommenttoEmailTest {
static testMethod void testMatching(){
// Id rtId = [select Id, name from RecordType where name = 'Massbay_Ticket' and SObjectType = 'Case' limit 1].Id;
//create account
Account acc = new Account();
//enter details
acc.Name = 'Test Account';
//Add other fields
insert acc;
// create test contact
Contact con = TestUtilityController.getContact('Test Last Name','testing@testing.com',acc.Id);
insert con;
// Create test cases
List<Case> listCase = new List<Case>();
if(UtilityController.caseRecordType.containsKey('Massbay_Ticket')){
String recordTypeId = UtilityController.caseRecordType.get('Massbay_Ticket').Id;
Case csa = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
//enter details
//Add other fields
csa.Ticket_Category__c='Blackboard learn';
csa.Status = 'Action-Automated Escalation';
insert csa;
PageReference pageRef = Page.MyNew_commentvf;
pageRef.getParameters().put(recordTypeId, String.valueOf(csa.Id));
Test.setCurrentPage(pageRef);
CaseComment tComment = new CaseComment();
tComment.ParentId = Csa.Id;
tComment.CommentBody = 'Some Comment';
tComment.IsPublished = TRUE;
insert tComment;
tComment.CommentBody = 'Inporgreess Comment';
update tComment ;
ApexPages.StandardController sc = new ApexPages.StandardController(csa);
CommenttoEmail testCmEmail = new CommenttoEmail (sc);
testCmEmail.senttoEmail();
testCmEmail.bccEmail();
testCmEmail.ccEmail();
testCmEmail.attachemail();
testCmEmail.createCaseComment();
testCmEmail.sendingEmail();
testCmEmail.ss();
testCmEmail.ChangeStatus();
testCmEmail.getCaseStatus();
testCmEmail.upload();
}
}// end of test method
}// end of Class
My apex class here
@istest
public class CommenttoEmailTest {
static testMethod void testMatching(){
// Id rtId = [select Id, name from RecordType where name = 'Massbay_Ticket' and SObjectType = 'Case' limit 1].Id;
//create account
Account acc = new Account();
//enter details
acc.Name = 'Test Account';
//Add other fields
insert acc;
// create test contact
Contact con = TestUtilityController.getContact('Test Last Name','testing@testing.com',acc.Id);
insert con;
// Create test cases
List<Case> listCase = new List<Case>();
if(UtilityController.caseRecordType.containsKey('Massbay_Ticket')){
String recordTypeId = UtilityController.caseRecordType.get('Massbay_Ticket').Id;
Case csa = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
//enter details
//Add other fields
csa.Ticket_Category__c='Blackboard learn';
csa.Status = 'Action-Automated Escalation';
insert csa;
PageReference pageRef = Page.MyNew_commentvf;
pageRef.getParameters().put(recordTypeId, String.valueOf(csa.Id));
Test.setCurrentPage(pageRef);
CaseComment tComment = new CaseComment();
tComment.ParentId = Csa.Id;
tComment.CommentBody = 'Some Comment';
tComment.IsPublished = TRUE;
insert tComment;
tComment.CommentBody = 'Inporgreess Comment';
update tComment ;
ApexPages.StandardController sc = new ApexPages.StandardController(csa);
CommenttoEmail testCmEmail = new CommenttoEmail (sc);
testCmEmail.senttoEmail();
testCmEmail.bccEmail();
testCmEmail.ccEmail();
testCmEmail.attachemail();
testCmEmail.createCaseComment();
testCmEmail.sendingEmail();
testCmEmail.ss();
testCmEmail.ChangeStatus();
testCmEmail.getCaseStatus();
testCmEmail.upload();
}
}// end of test method
}// end of Class
and my test class is
@istest
public class CommenttoEmailTest {
static testMethod void testMatching(){
// Id rtId = [select Id, name from RecordType where name = 'Massbay_Ticket' and SObjectType = 'Case' limit 1].Id;
//create account
Account acc = new Account();
//enter details
acc.Name = 'Test Account';
//Add other fields
insert acc;
// create test contact
Contact con = TestUtilityController.getContact('Test Last Name','testing@testing.com',acc.Id);
insert con;
// Create test cases
List<Case> listCase = new List<Case>();
if(UtilityController.caseRecordType.containsKey('Massbay_Ticket')){
String recordTypeId = UtilityController.caseRecordType.get('Massbay_Ticket').Id;
Case csa = TestUtilityController.getCase(recordTypeId,con.Id,acc.Id);
//enter details
//Add other fields
csa.Ticket_Category__c='Blackboard learn';
csa.Status = 'Action-Automated Escalation';
insert csa;
PageReference pageRef = Page.MyNew_commentvf;
pageRef.getParameters().put(recordTypeId, String.valueOf(csa.Id));
Test.setCurrentPage(pageRef);
CaseComment tComment = new CaseComment();
tComment.ParentId = Csa.Id;
tComment.CommentBody = 'Some Comment';
tComment.IsPublished = TRUE;
insert tComment;
tComment.CommentBody = 'Inporgreess Comment';
update tComment ;
ApexPages.StandardController sc = new ApexPages.StandardController(csa);
CommenttoEmail testCmEmail = new CommenttoEmail (sc);
testCmEmail.senttoEmail();
testCmEmail.bccEmail();
testCmEmail.ccEmail();
testCmEmail.attachemail();
testCmEmail.createCaseComment();
testCmEmail.sendingEmail();
testCmEmail.ss();
testCmEmail.ChangeStatus();
testCmEmail.getCaseStatus();
testCmEmail.upload();
}
}// end of test method
}// end of Class
Method failed again with to many soql query 101 error.