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
Alejandro Garcia LopezAlejandro Garcia Lopez 

how to do a test class for a trigger on a custom object

Hi, i don't understand how to do reference from the trigger in the class, i need the test
this is my trigger 

trigger VendidasDisponiblesEstado on Estados__c (before update) {
        for (Estados__c c:Trigger.new)
    {
integer i=[select count() from oferta__c where Estatus__c = 'cobrada' AND id=:c.id];
c.vendidas__c=i;
integer d=[SELECT count() FROM Oferta__c WHERE TiempoOferta__c >= -1500 AND PrecioVenta__c <= 5000000 
               AND Estatus__c != 'Descartada' AND FechaCobro__c = Null AND FechaPago__c != Null 
               AND ((Etapa__c IN ('Compilación expediente compra','Compra final',
                                  'Escrituras en proceso registro','Compilación expediente cliente')) 
                                  OR (Etapa__c IN ('Rehabilitación') AND Invadida__c = true))
                                  AND Estado__c=:c.id ];
               c.Propiedades_disponibles__c=d;            
}

}
Best Answer chosen by Alejandro Garcia Lopez
LBKLBK
Sorry I couldn't really understand much of the WHERE clauses above.

But I have come up with a pseudo code here.
 
@isTest
private class TestTriggerVendidasDisponiblesEstado {
    @isTest static void TestTriggerVendidasDisponiblesEstado1() {
        //Step 1
		//Create a record in Estados__c
		
		//Step 2
		//Create a record in oferta__c where Estatus__c = 'cobrada' AND id= id from above entry
		
		//Step 3
		//Create a record in oferta__c to meet the condition in 
		
		execute an update on the Estados__c record.		
    }
Hope this helps.