@isTest private class BeforeSSOpportunityBatchTest { @isTest static void updateTest() { // Implement test code Opportunity opp1 = new Opportunity(Name='aiueo1', StageName='引合', CurrencyIsoCode='USD', CloseDate=Date.today(),Close_Forecasted_Date__c=Date.today()); Opportunity opp2 = new Opportunity(Name='aiueo2', StageName='引合', CurrencyIsoCode='CNY', CloseDate=Date.today(),Close_Forecasted_Date__c=Date.today()); insert new Opportunity[] {opp1, opp2}; List opp = [select id,StageName from Opportunity]; System.assertEquals(opp[0].StageName, '引合'); System.assertEquals(opp[1].StageName, '引合'); System.Test.StartTest(); Id execBTId = Database.executeBatch(new BeforeSSOpportunityBatch(), 5); System.Test.StopTest(); opp1 = [select id,Monthly_ship_target_txt__c,Monthly_ship_target__c,Monthly_order_target_txt__c,Monthly_order_target__c from Opportunity where Id=:opp1.Id]; opp2 = [select id,Monthly_ship_target_txt__c,Monthly_ship_target__c,Monthly_order_target_txt__c,Monthly_order_target__c from Opportunity where Id=:opp2.Id]; System.assertEquals(opp1.Monthly_ship_target_txt__c, opp1.Monthly_ship_target__c ? '1':'0'); System.assertEquals(opp1.Monthly_order_target_txt__c, opp1.Monthly_order_target__c ? '1':'0'); System.assertEquals(opp2.Monthly_ship_target_txt__c, opp2.Monthly_ship_target__c ? '1':'0'); System.assertEquals(opp2.Monthly_order_target_txt__c, opp2.Monthly_order_target__c ? '1':'0'); } }