function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Krystal D.  CarterKrystal D. Carter 

Test Class Error: Argument must be an object that implements Database.Batchable

Hi I'm getting the same the  following error on my test class: "Argument must be an object that implements Database.Batchable"
I've used this code multiple times before in regards to an Apex Sharing Rule.  But in this org it's throwing an error.  I've bolded the line that's throwing the error. Any help would be appreciated. 



@istest
public class  testAgreementsharecalc
{
     Public static testMethod void testingagreementsharecalc()
     {
        Test.startTest();
        agreementsharecalc sb = new agreementsharecalc();
        Apttus__APTS_Agreement__c objAgreement = new Apttus__APTS_Agreement__c();
        objAgreement.Apttus__Requestor__c = UserInfo.getUserId();
        insert objAgreement;
        
        ID batchprocessid = Database.executeBatch(sb);          
        Test.stopTest();
     }
}
sandeep reddy 37sandeep reddy 37
@isTest public class oppertunity_Test {
public static testmethod void testoppertunity() {
List<Account> listacc = new List<Account>();
Account acc1 = new Account(Name = 'TestAccountName');
Insert acc1;
List<Opportunity> listOpportunity = new list<Opportunity >();
for(Integer i = 0 ; i<=100 ;i++) { Opportunity opp1 = new Opportunity() ;
opp1.Name ='Test'+i;
opp1.accountid = acc1.id;
opp1.StageName = 'Closed Won';
opp1.CloseDate=Date.Today();
listOpportunity.add(opp1);
}
Test.startTest();
insert listOpportunity;
Test.stopTest();
}
}
i thaught you want do bulkfy operations on test class
i hope its is use full or not 
Amit Chaudhary 8Amit Chaudhary 8
Please try to update your Scheduler Test class like below
@istest
public class  testAgreementsharecalc
{
	public static String CRON_EXP = '0 0 0 15 3 ? 2022';

    Public static testMethod void testingagreementsharecalc()
    {
	
        Apttus__APTS_Agreement__c objAgreement = new Apttus__APTS_Agreement__c();
        objAgreement.Apttus__Requestor__c = UserInfo.getUserId();
        insert objAgreement;

        Test.startTest();
			
			String jobId = System.schedule( 'UserLogJobTest', CRON_EXP, new agreementsharecalc() );
			CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
			System.assertEquals(CRON_EXP, ct.CronExpression);
			System.assertEquals(0, ct.TimesTriggered);
			
        Test.stopTest();
    }
}
Let us know if this will help you

Thanks
Amit Chaudhary

 
Krystal D.  CarterKrystal D. Carter
Thanks I got it figured out. I added a line in the apex class for which the test was created.
Amit Chaudhary 8Amit Chaudhary 8
If your issue is resolved then please mark the best Answer and close this thread