You need to sign in to do that
Don't have an account?
hiteshwar marni
batch apex test class
global class accountamountupdate1 implements Database.Batchable<sObject>
{
global Database.queryLocator start(Database.BatchableContext bc)
{
string query='select id,AnnualRevenue from account';
return database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc,list<sObject> acclist)
{
system.debug('11111'+acclist);
list<account>updatelist= new list<account>();
for(sObject acc:acclist)
{
Account a = (Account)acc;
if(a.AnnualRevenue!=null){
a.AnnualRevenue+=a.AnnualRevenue;
system.debug('2222'+a);
updatelist.add(a);
}
}
update updatelist;
system.debug('33333'+updatelist);
}
global void finish(database.batchablecontext bc)
{
}
}
and test class for this is
@isTest
public class accountamountupdatetest
{
static testmethod void mhcmethodd()
{
list<account> acc = new list<account>();
account a;
for(integer i=0; i<10;i++)
{
a= new account();
a.name='name'+i;
acc.add(a);
}
insert acc;
Test.startTest();
accountamountupdate1 s = new accountamountupdate1();
database.executebatch(s);
Test.stopTest();
}
}
while I'm executing the class i'm getting following error .
Methods defined as TestMethod do not support Web service callouts
but I didn't used any webservice callouts in my batch.
thanks
{
global Database.queryLocator start(Database.BatchableContext bc)
{
string query='select id,AnnualRevenue from account';
return database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc,list<sObject> acclist)
{
system.debug('11111'+acclist);
list<account>updatelist= new list<account>();
for(sObject acc:acclist)
{
Account a = (Account)acc;
if(a.AnnualRevenue!=null){
a.AnnualRevenue+=a.AnnualRevenue;
system.debug('2222'+a);
updatelist.add(a);
}
}
update updatelist;
system.debug('33333'+updatelist);
}
global void finish(database.batchablecontext bc)
{
}
}
and test class for this is
@isTest
public class accountamountupdatetest
{
static testmethod void mhcmethodd()
{
list<account> acc = new list<account>();
account a;
for(integer i=0; i<10;i++)
{
a= new account();
a.name='name'+i;
acc.add(a);
}
insert acc;
Test.startTest();
accountamountupdate1 s = new accountamountupdate1();
database.executebatch(s);
Test.stopTest();
}
}
while I'm executing the class i'm getting following error .
Methods defined as TestMethod do not support Web service callouts
but I didn't used any webservice callouts in my batch.
thanks
It is not this tested class for sure that calls the Web service.
What are the triggers for account?