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
hmoh1920hmoh1920 

chedule test class

Hi,

I write a schedule :

 

global class Sch01 implements Schedulable{


   global void execute(SchedulableContext sc) {


     AccountOwnerReassignment acc = new AccountOwnerReassignment();


     database.executebatch(acc);

   }
}

 

and this test class;

static testmethod void t62()
{


Test.startTest();
        Sch01 sh = new Sch01();
        String sch = '0 0 5 * * ?';
        system.schedule('Schedule TEST', sch, sh);
Test.stopTest();      
        
}

 

Ihave this error :Save error: Method does not exist or incorrect signature: Test.startTest().

 

Please, what is the problem??

 

thanks!

 

M.H

 

blacknredblacknred

Change the name of the class, it can't be called 'Test' because you are overriding the system class.

Next time, googling the error might help you too.

hmoh1920hmoh1920

I renamed the class and it was the same problem!

blacknredblacknred

Make sure you first manage to save the class with a different name, and then edit it with the new test method.

If that doesn't work, Copy & Paste the whole class code so we can see it.

hmoh1920hmoh1920

This is my code of class test:

 

@isTest
private class test {
        
/***************************************************************************************************************************/    
public static testmethod void t1()
{

  
commission_et_frais_par_catalogue__c comFraisCat = new commission_et_frais_par_catalogue__c
(Code_catalogue__c='test');



         insert comFraisCat;    
    
}

/****************************************************************************************************************************/

 

/****************************************************************************************************************************/
public static testmethod void t2()
{
         AccountOwnerReassignment ch = new AccountOwnerReassignment();
         Database.executeBatch(ch);
        //Database.executeBatch(new AccountOwnerReassignment());
       
}
/****************************************************************************************************************************/
public static testmethod void t3()
{
    
  
     

    
        Sch01 sh = new Sch01();
        Datetime dt = Datetime.now();
        String sch = '0 '+dt.minute()+' * '+dt.day()+' '+dt.month()+' '+' ? '+dt.year();
        
        system.schedule('Schedule',sch,sh);
     
        
}

 

}

 

and this is my code of schedule class

 

 

global class Sch01 implements Schedulable{


   global void execute(SchedulableContext sc) {


       

        AccountOwnerReassignment acc = new AccountOwnerReassignment();


     database.executebatch(acc);

   }
}

 

noted: AccountOwnerReassignment is an batch class!

 

thanks.

 

 

 

 

blacknredblacknred

Your class is still called 'test'

 

(...)
private class test {
(...)

 

 

hmoh1920hmoh1920

I renamed "private class test" by " private class testMethode"

 

i have a new error:  "Save error: Type is not visible: test"