System.DmlException: Insert failed. First exception on row 0; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record, how to rectify kindly hep me
You get this error message when the record that you are updating is locked. To avoid this issue in a test class you should create your own test data inside your test class instead of relying on the data in the org. This is a best practice to avoid test failures in different sandboxes. Create or setup your data between Test.start() and Test.stop() before doing any validation or assertions.
Alternatively, there might be a batch job or data loader job updating records that you are trying to do dml on. Also a possibility but less like is lock contention due to account data skew.
hope this helps!