System.runAs(User){...}というもので、指定したユーザーでテストクラスを実行するっていうテクがありました。

@IsTest
private class MyTestClass {
  private static testMethod void myTest() {
    // データの準備
    List<customobject__c> exsists = [Select Id From CustomObject__c Where Name='hoge']; 
    if (!exsists.isEmpty()) {
        delete exsists;
    }
    CustomObject__c c = new CustomObject__c(Name='hoge');
    insert c; // テスト用データの作成
    User u = new User(); // テスト用ユーザの作成
    u.Name = 'test@example.com'; // NG! よく使われそうなユーザ名
    u.Email = 'test@example.com';
    u.LastName = 'LastName';
    u.profileid = UserInfo.getProfileId();
    u.emailencodingkey='ISO-8859-1';
    u.languagelocalekey='en_US';
    u.localesidkey='en_GB';
    u.timezonesidkey='Europe/London';
    String result;
    Test.startTest();
        System.runAs(u) {
            result = target.methodA();
        }
    Test.stopTest();
    System.assertEquals('sample', result);
  }
}