+ Start a Discussion

Test Class help

i want to create a test class for my trigger someone could help me with that?

trigger aiu_IfaceLimiteCreditoDiario on IfaceLimiteCreditoDiario__c (after insert, after update) {
		List<Account> Auxacc = new List<Account>();
		List<Account> ListAcc = [Select id,a.TipoLimite__c, a.LimiteCredito__c, a.C_digo_do_Cliente__c From Account a];
		for(IfaceLimiteCreditoDiario__c iface : Trigger.new){
		for(Account acc : ListAcc){
			if(String.valueOf(acc.C_digo_do_Cliente__c) == iface.CustomerNumber__c){
				Account accs  = acc;
				accs.LimiteCredito__c = iface.LimiteCredito__c;
				accs.TipoLimite__c = iface.TipoLimite__c;
				Auxacc.add (accs);
		update Auxacc;

Best Answer chosen by SolidLucas
James LoghryJames Loghry
Salesforce has some decent documentation on this.  This is the first link that pops up when googling "Creating a test class for an Apex Trigger".  https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_qs_test.htm

he gist is, you'll want to create a test class and one or more test methods which insert IfaceLimiteCreditoDiario__c records.  You'll then need to add asserts to verify that your trigger is working as expected.  The more test methods and more asserts the better.