【发布时间】:2012-03-13 09:48:56
【问题描述】:
我有一个批处理顶点类
global class apexBatch implements Database.Batchable<sObject>{
global final string query;
List<user> lstUser= new List<user>();
Set<id> setUserID= new Set<id>();
//constructor
global apexBatch () {
if (system.Test.isRunningTest())
{
this.query='SELECT id FROM user limit 100';
}
else
{
this.query='SELECT id FROM user ;
}
}
global Database.QueryLocator start(Database.BatchableContext BC) {
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<sObject> scope) {
// do some processing
}
global void finish(Database.BatchableContext BC) {
}
我正在使用这段代码从测试类调用这个类
Test.startTest();
apexBatch ba = new apexBatch();
Database.executeBatch(ba);
Test.stopTest();
当我检查代码覆盖率时,我只能看到构造函数被覆盖,start 和 execute 方法根本没有被覆盖。
知道是什么原因造成的
谢谢
【问题讨论】:
标签: salesforce apex-code