I have been through Trailhead and read multiple references, but am still not getting passing tests. I'm sure I'm missing something simple and need assistance with writing a passing test for a method that returns a boolean value.
Here is the controller extension (method) I need to test.
public with sharing class ShouldShowMedSection{
public ShouldShowMedSection(ApexPages.StandardController paramController) {
Intake = paramController;}
public ApexPages.StandardController Intake {get; set;}
public Boolean getShouldShowMedSection() {
Intake__c record = (Intake__c)Intake.getRecord();
if(
record.Personal_Care__c != null && record.Personal_Care__c.contains('Medication')
)
{
return true;
}
return false;
}
}
Here is the test method I need assistance adjusting:
@isTest
public class IntakeExtensionTest {
static testMethod void ShouldShowMedSection() {
Intake__c i1 = new Intake__c();
Boolean isValid = false;
Test.StartTest();
i1.Client_Name_First_and_Last_Initial__c = 'Test Client A';
i1.Personal_Care__c.contains('Medication');
insert i1;
isValid = Intake__c.validate(i1);
Test.stopTest();
System.assert(isValid, true);
}
}