@Istest public class NewLeadFromContact2Test { static testMethod void testMethod01(){ RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp']; List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc]; Account acc = new Account(); acc.RecordTypeId = '01210000000QemG'; acc.Name = 'HP test1'; insert acc; Contact con = new Contact(); con.LastName = 'lastname2'; con.FirstName = 'firstname2'; con.AccountId = acc.id; con.Email = 'olympustest033@sunbridge.com'; con.MobilePhone = '99999999'; con.Work_Location_manual__c = 'location2'; con.Post_picklist__c = '部长'; con.Job_Category_picklist__c = '销售推广'; con.Hire_date_text__c = Date.today().addMonths(-6); con.Gender_text__c = '男'; con.dept__c = '服务本部'; con.Pregnant_Rest__c = true; insert con; NewLeadFromContact2.NewLeadFromContact2(con.id); } }