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
nilesh walkenilesh walke 

set User(use any user from your org except your user)as account owner if account status is Verification needed(Create new field status on account if you do not have that present already and add mentioned value). want its test class

Suraj Tripathi 47Suraj Tripathi 47
Hi,
I have written a test class and update the owner. You can change the code as per requirement.

      @isTest
public class accountOwnerTest 
{
    static testMethod void testDiffOwner() 
    {
        Account acc = new Account();
            acc.Name = 'Test';
        insert acc;
        
        
        Test.startTest();
            Profile p1 = [SELECT Id FROM Profile WHERE Name='System Administrator']; 
            User user1 = new User(Alias = 'stand', Email='standarduser@testorg.com', 
                        EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
                        LocaleSidKey='en_US', ProfileId = p1.Id, 
                        TimeZoneSidKey='America/Los_Angeles', UserName='standarduser@testorg.com');
            insert user1;
            System.runAs(usr)
            {
                acc.ownerId = user1.id;
                update acc;
            }
        Test.stopTest();       
    }
}

Please mark it as Best Answer if it helps you.

Thanks & Regards
Suraj Tripathi