Apex テストクラスコミュニティユーザ作成
Id p = [select id from profile where name='Partner Community User'].id;
Account ac = new Account(name ='Grazitti') ;
insert ac;
Contact con = new Contact(LastName ='testCon',AccountId = ac.Id);
insert con;
User user = new User(alias = 'test123', email='[email protected]',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = p, country='United States',IsActive =true,
ContactId = con.Id,
timezonesidkey='America/Los_Angeles', username='[email protected]');
insert user;
system.runAs(user) {
// statements to be executed by this test user.
}
https://www.forcetalks.com/salesforce-topic/can-we-insert-the-accountid-in-community-user/