1

I wrote my first Schedulable class in SF.

    global class Atualizar_Aging_OS implements Schedulable {

    global void execute(SchedulableContext SC) { 

        System.debug(LoggingLevel.ERROR, '___ [cls Atualizar_Aging_OS - execute()] - Inicio... ');

        String query = 'SELECT Id ' +
                            ', StartDate ' +
                            ', EndDate ' +
                            ', Aging__c ' + 
                            'FROM WorkOrder ';

        System.debug(LoggingLevel.ERROR, '___ [cls Atualizar_Aging_OS - execute()] - query: '+query);

        Atualizar_Aging_OS_Batch batch = new Atualizar_Aging_OS_Batch(query);
        Database.executeBatch(batch, 200); 

    } // Fim execute

}

I've searched for a test class and I'm getting the message: Add test methods to your test class.

@isTest
public class Teste_Atualizar_Aging_OS {

    //Método para testar o agendamento do Aging
    public static void testschedule() {

        Test.StartTest();
        Atualizar_Aging_OS sh1 = new Atualizar_Aging_OS();      
        String sch = '0 37 11 * * ?';
        system.schedule('Test check', sch, sh1);
        Test.stopTest();

    }     
}

Sorry, I'm a begginer in programming. What kind of method should I create to test this class?

1

You have to use testMethod modifier for your method in test class to make it a test method.

@isTest
public class Teste_Atualizar_Aging_OS {

    //Método para testar o agendamento do Aging
    public static testMethod  void testschedule() {

        Test.StartTest();
        Atualizar_Aging_OS sh1 = new Atualizar_Aging_OS();      
        String sch = '0 37 11 * * ?';
        system.schedule('Test check', sch, sh1);
        Test.stopTest();

    }     
}

Src: https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.