You need to sign in to do that
Don't have an account?
kiran punuru
How to cover the lines after for loop
Hi All,
Can Someone tell me how to cover the lines of code inside for loop .
My Class is:
public with sharing class MyClass{
public static void (String userId,List<String> oppids)(){
List<Opportunity> lstopp = new List<Opportunity>();
for(Opportunity opp :[Select id ,name,Probability from Opportunity where Probability == 50]){
if(opp.probability == 50){
opp.probability = 65;
lstopp.add(opp);
}
}
Can Someone tell me how to cover the lines of code inside for loop .
My Class is:
public with sharing class MyClass{
public static void (String userId,List<String> oppids)(){
List<Opportunity> lstopp = new List<Opportunity>();
for(Opportunity opp :[Select id ,name,Probability from Opportunity where Probability == 50]){
if(opp.probability == 50){
opp.probability = 65;
lstopp.add(opp);
}
}
public class MyClassTest {
static testMethod void myTest() {
List<Opportunity> oppList = new List<Opportunity>();
Opportunity opp1 = new Opportunity(Name = 'opp1',Probability =50,CloseDate = System.today(),StageName ='ClosedWon');
oppList.add(opp1);
Opportunity opp2 = new Opportunity(Name = 'opp2',Probability =45,CloseDate = System.today(),StageName ='ClosedWon');
oppList.add(opp2);
insert oppList;
MyClass.buildlstopp(UserInfo.getUserId(),new List<String>{'',''});
}
}
That should cover the code based on the way it is written. Are you using the List of Strings and UserId in the method somewhere?