Can someone please help me how can I get the code coverage for below line:
Test class code:
@istest
public class Testownerassisgnbasedonaccount {
@isTest static void TestDeleteAccountWithOneOpportunity() {
// Test data setup
// Create an account with an opportunity, and then try to delete it
Lead le=new Lead(
FirstName='Hqwewqinwedu',
LastName='H',
Company='Park controls',
phone='2568552',
country='India'
);
Insert le;
List<string> cmpny=new List<String>();
Map<string,Id> mp1=new Map<string,Id>();
Account acct = new Account(Name='Test Account',Billingcountry='India',Industry='Energy',Activity__c='Distributor');
insert acct;
cmpny.add('Test Account');
system.debug(cmpny);
List<Account> ACC = [select Phone,Name,Id,OwnerId from Account where Name Like:cmpny LIMIT 1];
System.debug(ACC);
for(Account ac:ACC){
mp1.put(ac.name,ac.ownerId);
}
Lead lne=new lead();
lne.FirstName='Pweawqeqwerk';
lne.LastName='Cwqeontrweqweols';
lne.company=acct.Name;
lne.OwnerId=acct.ownerId;
Insert lne;
}
}
Thanks in advance!...
leadAccountIds.size()==1
. Have you satisfying this condition in your test class? means, Is your test-data returning only one record which satisfy your query?