Use a System. runAs () block to update the contact. By and large, all Apex code keeps running in system mode , where the authorizations and record sharing of the present user are not considered. The system technique runAs empowers you to compose test strategies that change the user context to a current user or another user so the user's record sharing is upheld. The runAs strategy doesn't implement user consents or field-level authorizations, just record sharing.
You can utilize runAs just in test techniques. The first system context is begun again after all runAs test techniques finish
You can likewise utilize the runAs technique to perform blended DML activities in your test by encasing the DML tasks inside the runAs block. Along these lines, you sidestep the blended DML mistake that is generally returned when embeddings or refreshing setup objects together with different sObjects