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
aswanijagadesh1.397398535585991E12aswanijagadesh1.397398535585991E12 

Test for trigger?

Hai ,i am new to test casees so can any one help me how to write test case for following code
trigger PrefixDoctor on Lead (before insert,before update)
{
List<Lead> leadList = trigger.new;
for(Lead l: leadList)
{
l.firstname = 'Dr.'+ l.firstname;
}
}
Sri549Sri549
Hello aswan,
As per your requirment of test class,i have gone through it and tried about.

@IsTest
Public class Test_PrefixDoctor
{
    Public static testmethod void PrefixDoctor()
    {
        Lead l = new Lead();
        l.FirstName='Test';
        l.LastName='Test2';
        l.Company='Cmy';
        Insert l;
        System.AssertEquals(l.Id!=null,True);   
    } 
}

If it gives you solutions please mark as solutions for KUDOS  or else get back to me with your requirment clearly.


aswanijagadesh1.397398535585991E12aswanijagadesh1.397398535585991E12
i have a some doubt ,for apex classes we create a object in test class so that this  testcase is belongs to particuler class ,then for this trigger how can i know 
Sri549Sri549

Hello
Name of trigger(PrefixDoctor) would be test class name(Test_PrefixDoctor) through which we can identify.


Thanks 
Srinivas
aswanijagadesh1.397398535585991E12aswanijagadesh1.397398535585991E12
ok thank you srinivas