Hi,this program shows test class for trigger
Trigger
trigger TestTrigger on Lead (before insert) {
for(Lead l:trigger.new){
if(l.Leadsource=='Web'){
l.Rating='Warm';
}
}
}
Test Class
@isTest
private class TestTriggerLead {
static testMethod void testme(){
Lead l=new Lead();
l.LastName='Testing';
l.FirstName='Salesforcecodes';
l.Company='Wipro';
l.LeadSource='Web';
insert l;
Lead leads=[select rating from Lead where id=:l.Id];
system.assertEquals('Warm', leads.Rating);
}
}