You need to sign in to do that
Don't have an account?

Test class for team member
Hi any one help me to write test class for this code? I tried but not getting enough code coverage.
List<AccountTeamMember> accountTeamList = [select userId,AccountId from AccountTeamMember where userId IN :userIds];
Map<Id, user> ObjMap = new Map<Id, user>([select id,unit, function from user where Id IN :userIds AND IsActive=true]);
List<AccountTeamMember> updatedaccountlist = new List<AccountTeamMember>();
for (AccountTeamMember am : accountTeamList )
{
if(ObjMap.containsKey(am.userId)) //Validate Account userId and Userrecord Userid are equal
{
User obj = ObjMap.get(am.userId);
AccountTeamMember teamrole =new AccountTeamMember();
teamrole.userId = obj.User_ID_18__c;
teamrole.AccountId= am.AccountId;
if (obj.unit != null && obj.function != null)
{
teamrole.TeamMemberRole = obj.unit +' '+ obj.function;
}
else
{
teamrole.TeamMemberRole = 'Unspecified';
}
updatedaccountlist.add(teamrole);
}
}
insert updatedaccountlist;
List<AccountTeamMember> accountTeamList = [select userId,AccountId from AccountTeamMember where userId IN :userIds];
Map<Id, user> ObjMap = new Map<Id, user>([select id,unit, function from user where Id IN :userIds AND IsActive=true]);
List<AccountTeamMember> updatedaccountlist = new List<AccountTeamMember>();
for (AccountTeamMember am : accountTeamList )
{
if(ObjMap.containsKey(am.userId)) //Validate Account userId and Userrecord Userid are equal
{
User obj = ObjMap.get(am.userId);
AccountTeamMember teamrole =new AccountTeamMember();
teamrole.userId = obj.User_ID_18__c;
teamrole.AccountId= am.AccountId;
if (obj.unit != null && obj.function != null)
{
teamrole.TeamMemberRole = obj.unit +' '+ obj.function;
}
else
{
teamrole.TeamMemberRole = 'Unspecified';
}
updatedaccountlist.add(teamrole);
}
}
insert updatedaccountlist;
try this code
Try this