标签:rtt span lis eth src name sql select des
测试future方法的异步执行 public with sharing class FutureSample { //future在自己线程中运行,直到资源可用才运行 @future public static void futuremethod(List<String> ids){ String sql = ‘select Id,Name from Merchandise__c where Name in : ids‘; List<Merchandise__c> accounts = Database.query(sql); for(Merchandise__c account : accounts){ System.debug(account.Id); } } }
测试类
@isTest private class Test_FutureSample { //future方法的执行必须在startTest和stopTest之间 static testMethod void myUnitTest(){ Test.startTest(); List<String> ids = new String[]{‘DeskTop‘,‘Keyboard‘}; FutureSample.futuremethod(ids); Test.stopTest(); } }
标签:rtt span lis eth src name sql select des
原文地址:http://www.cnblogs.com/weizhen/p/6407644.html