When trying to assign values to a multi-picklist field in test class, I'm facing the above error. Please take a look below my controller and test class.
Controller
List<String> issues = (List<String>) JSON.deserialize(caseDetail.Test__c, List<String>.class);
for(String strIssue : issues) {
if(delimiter == '' || delimiter == null) {
delimiter = strIssue;
}
else {
delimiter += ';' + strIssue;
}
}
NewCaseToUpdate.Test__c = delimiter;
Test class :
List<String> issueList = new List<String>();
issueList.add('Engineering Samples');
testCase.Test__c = JSON.serialize(issueList);
Test__c
, please add one of a valid value.system.debug()
lines so you can get an idea of what data variables hold, what the result of a boolean operation is, etc... Setting that aside, is there a reason why you're not usingString.join()
in your controller?