Need Help in writting Test Class when Permission set is assigned via Role??
UserRole role = new UserRole(DeveloperName = 'Sales Manager', Name = 'Sales Manager'); insert role; User u = new User( ProfileId = [SELECT Id FROM Profile WHERE Name = 'YOUR PROFILE'].Id, LastName = 'last', Email = 'testtt@tessst.com', Username = 'testtt@tessst.com' + System.currentTimeMillis(), CompanyName = 'TEST', Title = 'title', Alias = 'alias', TimeZoneSidKey = 'America/Los_Angeles', EmailEncodingKey = 'UTF-8', LanguageLocaleKey = 'en_US', LocaleSidKey = 'en_US', UserRoleId = role.Id ); Insert u; PermissionSet perSet = [SELECT Id FROM PermissionSet WHERE Name='PERMISSION SET NAME']; PermissionSetAssignment permAssnment = [SELECT Id, AssigneeId FROM PermissionSetAssignment WHERE AssigneeId= :u.Id LIMIT 1]; System.assertEquals(perSet.Id,permAssnment.PermissionSetId);