I have a function createWithRecordTypeIfExists(String recordType)
. Its logic goes like this:
Check whether a record type for this object exists in the org.
- If yes, create a new record with this record type.
- If no, create a new record with
recordTypeId
null.
My question is: how do I unit test this logic?
Shall I do assert
like below?
But it doesn't feel like a unit test
anymore, too heavy and conditional embedded.
if(recordTypeExists()){
//assert validate recordTypeId fetched from the org;
}else{
//assert validate recordTypeId == null;
}