You need to sign in to do that
Don't have an account?
Doondi
How to write test class for if (list.size > 0 )?
Hello Dev's
Please help me to write test class for If(list.size >0 )
here is my trigger code
What I tried till now is I have created data for all the objects and I am getting coverage for that, but I am not able to pass this If(list.size > ) ) condition
it's very urgent.
Please help me to write test class for If(list.size >0 )
here is my trigger code
List <Project__c> ProjectList = [select id,Name,OwnerId from Project__c where Name =: Name]; // Region__c is custom settings to avoid hard coding ID's of particular profile to which record should be assigned if it meets Region__c condigion on deal object) Region__c user = Region__c.getInstance(Userinfo.getUserId()); if (ProjectList.size() == 0) { if(deal.Manager__c == Null && deal.Property__r.Region__c == 'Asia') { deal.Manager__c = user.Asia__c; } Projects.add(new Project__c (Name = 'test Name', OwnerId = deal.Manager__c )); insert Project; } else if ((ProjectList.size() > 0)) { if(deal.Manager__c == Null && deal.Property__r.Region__c == 'Asia') { deal.Manager__c = user.Asia__c; } String Name : deal.Name Project__c NewProjectList = [select id,Name,OwnerId from Project__c where Name =: Name]; NewProjectList.OwnerId = deal.Manager__c; update NewProjectList; }
What I tried till now is I have created data for all the objects and I am getting coverage for that, but I am not able to pass this If(list.size > ) ) condition
it's very urgent.
To cover the if block add like below