@isTest private class Rental_Apply_App_CCEmailTest { @IsTest() static void testMethod1() { List columns = [select Category5_F__c, CCEmail__c from Rental_Apply_App_CCEmail__mdt]; if (columns.size() > 0) { Set fieldset = new Set(); for (Rental_Apply_App_CCEmail__mdt col : columns) { Boolean b1 = String.isNotBlank(col.Category5_F__c); Boolean b2 = String.isNotBlank(col.CCEmail__c); system.assert(b1 && b2, '审批抄送人设置Category5, 抄送邮件的项目为空。'); fieldset.add(col.CCEmail__c); } String queryStr = 'select '+ String.join(new List(fieldset), ', ') + ' from Rental_Apply__c limit 1'; try { Database.query(queryStr); } catch(Exception ex) { system.assert(false, ex); } } } }