You need to sign in to do that
Don't have an account?
fbell
Problems with Code Coverage and Testing
I have a basic Custom Controller working fine on my sandbox but I'm having the most difficult time getting any code coverage %. I can't tell what I have to do in order to get this covered to 75% because it is at 0% no matter what I have done now even though I have ran the following test or a variation of it successfully.
----
@isTest
private class changeCapacityControllerTestClass {
static testMethod void changeCapacity() {
//setdate = datetime.newInstance(1960, 2, 17);
date myDate = date.newInstance(1960, 2, 17);
Socket__c s = new Socket__c(Availability_Zone__c='a13e0000000g8QI', Activation_Date__c=mydate,Socket_Additions__c=33 );
System.debug('AvailZone ' + s.Availability_Zone__c);
System.debug('Activation Date: ' + s.Activation_Date__c);
System.debug('sockets' + s.Socket_Additions__c);
System.debug('Nothing: ' + 'blah');
// Insert
insert s;
// Retrieve the new Socket Addition
s = [SELECT Socket_Additions__c FROM Socket__c WHERE Activation_Date__c =:s.Activation_Date__c];
System.debug('Socket Count after this was ran: ' + s.Socket_Additions__c);
// Test that the stuff worked
//System.assertEquals('a13e0000000g8QI', s.Availability_Zone__c);
System.assertEquals(33, s.Socket_Additions__c);
System.assertEquals(mydate, s.Activation_Date__c);
}
}
----
@isTest
private class changeCapacityControllerTestClass {
static testMethod void changeCapacity() {
//setdate = datetime.newInstance(1960, 2, 17);
date myDate = date.newInstance(1960, 2, 17);
Socket__c s = new Socket__c(Availability_Zone__c='a13e0000000g8QI', Activation_Date__c=mydate,Socket_Additions__c=33 );
System.debug('AvailZone ' + s.Availability_Zone__c);
System.debug('Activation Date: ' + s.Activation_Date__c);
System.debug('sockets' + s.Socket_Additions__c);
System.debug('Nothing: ' + 'blah');
// Insert
insert s;
// Retrieve the new Socket Addition
s = [SELECT Socket_Additions__c FROM Socket__c WHERE Activation_Date__c =:s.Activation_Date__c];
System.debug('Socket Count after this was ran: ' + s.Socket_Additions__c);
// Test that the stuff worked
//System.assertEquals('a13e0000000g8QI', s.Availability_Zone__c);
System.assertEquals(33, s.Socket_Additions__c);
System.assertEquals(mydate, s.Activation_Date__c);
}
}
As per what I get. Your test ran successfully. But still your code coverage is 0%.
And if it so, can you show the code of your custom controller?
Because then only something can be done to increase the code coverage.