function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gorka SanzGorka Sanz 

TestClass for a VF Controller

Hi to all.
I'm new in salesforce. I create a large number of apex classes with their testclasses without problem. But now i have a VF page with its own controller:
public class QADDatosFACTController {
public String currentRecordId {get;set;}
public String parameterValue {get;set;}
public Account acc{get;set;}
public List<string> QADFACT {get;set;}
public String connQAD {get;set;}
    public QADDatosFACTController(ApexPages.StandardController controller) {
        try {
        //recoger el parametro de conexion de QAD
        string vName = 'QAD';
        connQAD =[select ValorTexto__c from Parametros__c where Name = :vName].ValorTexto__c;
        currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
        acc = [select id ,name, AccountNumber, Type, ID_CLIENTE_QAD__c from Account where id =: currentRecordId ];
        parameterValue = ApexPages.CurrentPage().getparameters().get('nameParam');
        // parseo de ordenes de venta
        httpsIntegracionesCrmDvpClWscrmS.DvpWsCrmPort qad = new httpsIntegracionesCrmDvpClWscrmS.DvpWsCrmPort();
        //httpsIntegracionesCrmDvpClWscrmS.getOvencResponseType resultado = qad.getOvenc ('1693090894a511ad4b8f1119c6a60b59','96792430');
        httpsIntegracionesCrmDvpClWscrmS.getFacVenResponseType resultado = qad.getFacVen (connQAD,acc.ID_CLIENTE_QAD__c);
        string json = resultado.facturas;
        Getfact r = Getfact.parse(json);
        //crear la lista de ordenes de venta
        QADFACT = new List<String> ();
        for(Integer i=1;i<r.facturasRow.size();i++)
    catch (Exception e)
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'Mensaje sin datos. Posible cliente sin facturas vencidas');

VF Page
<apex:page standardController="Account" extensions="QADDatosFACTController"> 
  <!--All JS Libraries and CSS required for this example-->;
<apex:includeScript value=""/>
<apex:includeScript value=""/>
<apex:includeScript value=""/>
<apex:stylesheet value=""/>
<apex:stylesheet value=""/>
    <apex:pagemessages />
            <table id="accTable" class="display" cellspacing="0" width="100%">
            <!-- Use apex:repeat to render each account record as a row and cell for the table-->
                    <apex:repeat value="{!QADFACT}" var="QAD">

This works fine in a sandbox. But i'm not able to create the correct testclass. This is my best effort:
public class testFacturasVencidasController {
 static testMethod void testControladorFactVencidas()
 {//inicio del metodo
    //referencia a la pagina
     PageReference pageRef = Page.QAD_Facturas_Vencidas;
     //localizar una cuenta. Usar la que tengo como ejemplo de soap
    list <Account> Cliente =[SELECT Id from Account where LLAVE_CRM__c = '12345678']; 
     //la llamada al controlador
     ApexPages.StandardController sc = new ApexPages.StandardController(Cliente[0]);
     QADDatosFACTController qad = new QADDatosFACTController(sc);
     //List <QADDatosFACTController> lstqad = qad.QADFACT[0];
     List <string> lstqad = qad.QADFACT;


What am i doing wrong? I need a bit of help.

Thanks in advance