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
Akshay AlandkarAkshay Alandkar 

want test class for

public void AccountVerification(List<Account> account3){
        USER u=[SELECT Id,Name,username,Alias FROM User WHERE Name='barak obama'];
        for(Account acc:account3){
            if(acc.Status__c=='Verification Needed'){
                acc.OwnerId=u.Id;
            }
        }
    }
    
    public void REIError(List<Account> account3){
       for(Account acc:account3)
        {
          string testName='REI';
          if(acc.Name.Contains(testName))
            {
              acc.addError('The Account Name Should Not contain REI Text Value.');
            }
            else
            {
                if(acc.Name.Contains('__Test')){
                    //do nothing
                }
                else{
                    acc.name=acc.name+'__Test';
                }
            }
        }
    }
    
CharuDuttCharuDutt
Hii Akshay
Try Below Code
@isTest
public class ContactHelperClassTest {
@isTest
    public static void UnitTest(){
        list<Account> lstAcc = new list<account>();
       Profile p = [SELECT Id FROM Profile WHERE Name='Office Profile'];
        User usr = new User(LastName = 'obama',
                            FirstName='barak',
                            Alias = 'simplSam',
                            Email = 'ssamsimple@asdf.com',
                            Username = 'ssamsimple@asdf.com',
                            ProfileId = p.id,
                            TimeZoneSidKey = 'GMT',
                            LanguageLocaleKey = 'en_US',
                            EmailEncodingKey = 'UTF-8',
                            LocaleSidKey = 'en_US'
                           );
        insert usr;
        system.runAs(usr){
            Account Acc = new Account();
            Acc.Name= 'Test';
            Insert Acc;
            
            lstAcc.add(Acc);
             Account Acc1 = new Account();
            Acc1.Name= 'TestREI';
            Insert Acc1;
            lstAcc.add(Acc1);
        }
		ContactHelperClass chc = new  ContactHelperClass();
        chc.AccountVerification(lstAcc);
        chc.REIError(lstAcc);
    }
}
Please Mark It As Best Answer If It Helps
Thank You!
Akshay AlandkarAkshay Alandkar
This Error Occures 
Static method cannot be referenced from a non static context: void AccountHelperClass.AccountVerification(List<Account>)
CharuDuttCharuDutt
Hii Akshay
Try Below Code
@isTest
public class ContactHelperClassTest {
@isTest
    public static void UnitTest(){
        list<Account> lstAcc = new list<account>();
       Profile p = [SELECT Id FROM Profile WHERE Name='Office Profile'];
        User usr = new User(LastName = 'obama',
                            FirstName='barak',
                            Alias = 'simplSam',
                            Email = 'ssamsimple@asdf.com',
                            Username = 'ssamsimple@asdf.com',
                            ProfileId = p.id,
                            TimeZoneSidKey = 'GMT',
                            LanguageLocaleKey = 'en_US',
                            EmailEncodingKey = 'UTF-8',
                            LocaleSidKey = 'en_US'
                           );
        insert usr;
        system.runAs(usr){
            Account Acc = new Account();
            Acc.Name= 'Test';
            Insert Acc;
            
            lstAcc.add(Acc);
             Account Acc1 = new Account();
            Acc1.Name= 'TestREI';
            Insert Acc1;
            lstAcc.add(Acc1);
        }
		AccountHelperClass chc = new  AccountHelperClass();
        chc.AccountVerification(lstAcc);
        chc.REIError(lstAcc);
    }
}
Please Mark It As Best Answer If It Helps
Thank You!
Akshay AlandkarAkshay Alandkar
Still Same error occures
 
Akshay AlandkarAkshay Alandkar
Static method cannot be referenced from a non static context: void AccountHelperClass.REIError(List<Account>)