function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sujit KarandeSujit Karande 

Check for string value in test class

I have an apex class which checks for the value of String. For eg :
String region = opportunity.Region_c;
if(region!=null){
  if(region.equals('India')){
    //Do someting
  }
  else if(region.equals('US')){
     // do something
  }
}
And I have written a test class but it only tests if(region!=null) and inner if conditions are not getting tested which is why it is not reaching the criteria of 75% of code coverage.

Any suggestion how could I do this?
 
Ryan GreeneRyan Greene
If the test is skipping your inner ifs, it must not have an opportunity.Region__c set in your test. If it is set on your test, could you share your test class to see if there's an issue there?