You need to sign in to do that
Don't have an account?
Test Method failures
I am having my first attempt at writing a test method. I am slowly getting the coverage up, but I also manage to get a failure on each test.
Any suggestions would be much appreciated.
Test Method:
@isTestprivate class DBGExtensionTest2 {
// Unit Test for general record creation
static testMethod void createGCTest() {
PageReference pageRef = Page.GroupCallPageDBG;
Test.setCurrentPage(pageRef);
contactSearchDBGExtension controller = new contactSearchDBGExtension();
Group_Call__c GroupCall = new Group_Call__c (Call_Type__c = 'Journal Club', CallStart__c = system.now(), Session_Length__c = '45 mins', State_National_ACtivity__c = 'State', PeopleTrained__c = '1 - 5');
controller.save();
system.assertEquals('Journal Club', GroupCall.Call_Type__c);
system.assert(GroupCall.CallStart__c != null);
system.assertEquals('45 mins', GroupCall.Session_Length__c);
system.assertEquals('1 - 5', GroupCall.PeopleTrained__c);
}
// Unit Test for fullSearch pageRef
static testMethod void fullSearchTest1() {
PageReference pageRef = Page.GroupCallPageDBG;
Test.setCurrentPage(pageRef);
contactSearchDBGExtension controller = new contactSearchDBGExtension();
controller.setName('PRM');
controller.setState('VIC');
controller.setSpecialty('General Practice');
List<Contact> l1 = controller.getResult();
controller.fullSearch();
system.assert( l1.size() == 0 );
controller.getConRes();
system.assertEquals( 'PRM', controller.getName());
system.assertEquals( 'VIC', controller.getState());
system.assertEquals( 'General Practice', controller.getSpecialty());
controller.allContactselected = true;
controller.getselectedContacts();
controller.saveSelectedContacts();
}
// Unit Test for partSearch pageRef
static testMethod void partSearchTest() {
PageReference pageRef = Page.GroupCallPageDBG;
Test.setCurrentPage(pageRef);
contactSearchDBGExtension controller = new contactSearchDBGExtension();
controller.setName('PRM');
controller.setState('NSW');
List<Contact> l2 = controller.getResult();
controller.partSearch();
system.assert( l2.size() >= 0 );
controller.getConRes();
system.assertEquals( 'PRM', controller.getName());
system.assertEquals( 'NSW', controller.getState());
controller.allContactselected = true;
controller.getselectedContacts();
controller.save();
}
}
The errors are as follows:
DBGExtensionTest2.createGCTest
DBGExtensionTest2.fullSearchTest
System.NullPointerException: Argument 1 cannot be null
Class.contactSearchDBGExtension.SaveSelectedContacts: line 148, column 50Class.DBGExtensionTest2.fullSearchTest1: line 36, column 9External entry point