Activity › Forums › Salesforce® Discussions › How to create a salesforce partner community user in test class? Tagged: Partner Community, Salesforce Development, Test Class Salesforce® Discussions How to create a salesforce partner community user in test class? Posted by Tanu on October 26, 2016 at 2:47 PM Hi All, How to create a salesforce partner community user in test class? Vikas Kumar replied 9 years, 3 months ago 2 Members · 1 Reply Partner CommunitySalesforce DevelopmentTest Class 1 Reply Vikas Kumar Member January 23, 2017 at 10:19 AM Hi Tanu, Below is the code for creating user in the test Method for the Partner Community 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=’test123@noemail.com’, 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=’tester@noemail.com’); insert user; system.runAs(user) { // statements to be executed by this test user. } Log In to reply. Public All Members My Connections Only Me PublicAll MembersMy ConnectionsOnly Me Public All Members My Connections Only Me