You need to sign in to do that
Don't have an account?
Error test class apex
Hi everybody,
Can you help me please, i have this error in my apex class test, and I don't know for why
ERROR: Error de compilación: Invalid constructor name: contactExtension en la línea 3 columna 16
@isTest
public class ContactTest {
public contactExtension(ApexPages.StandardController contactController) {
this.contact = (Contact)contactController.getRecord();
String idContact = contact.id;
}
static testmethod void myTestMethod1() {
Moneda__c monedabob = [select Name from Moneda__c where Moneda__c.name = 'Bolivianos'];
System.assert(monedabob != null);
String idMonedabob = monedabob.id;
Double x = 0;
for (Beneficio__c ben : [select monto_estimado__c from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedabob]){
x = ben.monto_estimado__c + x;
}
}
}
Regard,
Ale
This code:
is defining a constructor for the contactExtension class, but you are in a test class so that is illegal. This should be in a class named contactExtension and your test code should probably execute it.
All Answers
This code:
is defining a constructor for the contactExtension class, but you are in a test class so that is illegal. This should be in a class named contactExtension and your test code should probably execute it.
Please help me, this is new.
Regards,
The issue is you can't have a constructor in the test class - if you are testing a controller, you need to create an instance of the controller in the test class, not replicate the constructor.
Regards,