@IsTest public with sharing class NFM504ControllerTest { public NFM504ControllerTest() { } @testSetup static void makeTestRepair() { BatchIF_Transfer__c transfer1 = new BatchIF_Transfer__c(); transfer1.Table__c = 'QLMoldMark'; transfer1.Internal_Value__c = '*'; insert transfer1; List NFM501GainEndTimeTransfers = new List(); BatchIF_Transfer__c transfer2 = new BatchIF_Transfer__c(); transfer2.Table__c = 'NFM501GainEndTime'; transfer2.NFM501_Gain_End_Time__c = Datetime.now(); NFM501GainEndTimeTransfers.add(transfer2); insert NFM501GainEndTimeTransfers; List NFM501TokenTransfers = new List(); BatchIF_Transfer__c transfer3 = new BatchIF_Transfer__c(); transfer3.Table__c = 'NFM501Token'; transfer3.NFM501_Token__c = null;//'eyJhbGciOiJIUzUxMiJ9.eyJhcHBLZXkiOiIwNzBmMDBiZi02NGYxLTQ3MjAtYThkOC1iYmUxYWE5NzZkMjIiLCJhcHBTZWNyZXQiOiI2N0JCMkJBRkM4QUEwQkEwQ0FCQjM3Q0JGNTBFQzI5MiIsImV4cCI6MTYyNDI2MTc1OX0.s55zh9SSpwqRdp1wXH43_wEGpwlZtMfRgl1x8t69A-N0H7QrzRNmK5MNqNGGLhQ2LL_AbMSJmDfwO5chgwndoA'; NFM501TokenTransfers.add(transfer3); insert NFM501TokenTransfers; Tender_information__c Ten = new Tender_information__c(); Ten.Name = '123456'; Ten.ProjectId__c = '38_99df2844cf784982acdc61d00d7a7dbb'; insert Ten; Tender_information__c DTenInfo = new Tender_information__c(); Tender_information__c BTenInfo = new Tender_information__c(); DTenInfo.Name = '1122'; insert DTenInfo; BTenInfo.Name = '2211'; insert BTenInfo; // BatchIF_Transfer__c token504 = [Select ID, NFM501_Token__c FROM BatchIF_Transfer__c Where Table__c = 'NFM501Token']; BatchIF_Transfer__c token504 = new BatchIF_Transfer__c(); token504.Table__c = 'NFM501Token'; token504.NFM501_Token__c = ''; String token = token504.NFM501_Token__c; BatchIF_Transfer__c oldTime504 = new BatchIF_Transfer__c(); oldTime504.Table__c = 'NFM501GainEndTime'; //oldTime504。NFM501_Gain_End_Time__c = Datetime.now(); Datetime oldTime = oldTime504.NFM501_Gain_End_Time__c; } @IsTest static void myTest(){ Tender_information__c DTenInfo = [Select Id, InfoId__c, ProjectId__c, CursorMark__c, Retain_Tender__c From Tender_information__c Limit 1]; Test.startTest(); Test.setMock(HttpCalloutMock.class, new NFM504HttpCallMock()); NFM504Controller.sendRequest(DTenInfo.Id); Test.stopTest(); } }