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
Mahesh K 22Mahesh K 22 

Test Class for this before trigger

trigger acctrgr on Account (before insert) {
    for(account a : trigger.new){
        if(a.phone == null){
            a.phone.adderror('phone filed not equla to null');
        }
    }
}
Dilip_VDilip_V

Mahesh,

Try this class
 

@istest
Public class AcctrgrTest
{
@isTEst
Public static void TestMethod1()
{
Account acc=new Account();
Acc.name=''Test Accoun;
try 
{insert acc;}

Catch(Exception e)
​{
System.debusg(e);
}

}
}
Let me know if you have any issues.

Mark it as best answer if it works.

Thanks.