-
How can I cover the code coverage for multiple conditions in IF statement in Salesforce?
Below is the code for class:
public class ControllerHelper
{
public static boolean validate (Case obj)
{
if((obj.field1 = 'Yes' || obj.field2 = 'Yes') && checkNullValue(obj.field3))
||
((obj.field4 = 'Yes' || obj.field5 = 'Yes') && checkNullValue(obj.field6))
)
return true;
else
{
return false;
}
}public static boolean checkNullValue(String value)
{
if(value==null || value.trim().length()==0)
{
return true;
}
return false;
}
}
Log In to reply.
Popular Salesforce Blogs

Decorators in Salesforce
Salesforce is the best-known CRM in today’s world. It provides many functionalities that make our lives easier. Lightning web components and Apex classes are one…

MFA (Multi-Factor Authentication) in Salesforce
Introduction MFA is a special security feature provided by Salesforce that provides an extra layer of protection against suspicious or unauthorised logins. After enabling the…

Salesforce Lead Management: Tips And Best Practices
Customer relationship is a very important business segment. We will tell you about such a quality tool as Salesforce. Make Your Feedback Perfect - Salesforce…
Popular Salesforce Videos
How To Change Opportunity Stages In Salesforce
If you're finding that you need to change the stages of opportunity in Salesforce, don't worry, it's easy to do. In this video, Gary Smith…
Kanban View and Personalisation | Salesforce Training
In this short video, we will show you the Kanban view in Salesforce Lightning and how it can be personalized. Check out this amazing and…
What are Apps and Tabs in Salesforce?
In this video, Shrey is not only teaching but also demonstrating to you "What are Apps and Tabs in Salesforce?" You will be learning: 1.…